在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
赋值 assign:直接赋值、默认 @interface Car : NSObject { NSString *_name; } @property (assign,nonatomic) NSString *name; - (void) setName:(NSString *)name { _name = name; }
retain :保留对象 @interface Car : NSObject { NSString *_name; } @property (retain,nonatomic) NSString *name; - (void) setName:(NSString *)name { if (_name != name) { [_name release]; _name = [name retain]; } }
copy: 拷贝对象 @interface Car : NSObject { NSString *_name; } @property (copy,nonatomic) NSString *name; - (void) setName:(NSString *)name { if (_name != name) { [_name release]; _name = [name copy]; } } 三者的区别 assign:直接赋值,只是一个别名而已
readonly: 只读 noatomic: 多线程环境下,不存在线程保护 |
请发表评论