property
2019-08-03 本文已影响0人
水无月之痕
@property (nonatomic, strong) NSString *name;
那么其实生成的getter和setter相当于下面这样
-
(NSString *)name {
return _name;
} -
(void)setName:(NSString *)name {
[_name release];
[name retain];
_name = name;
}
@property (nonatomic, copy) NSString *name;
那么其实生成的getter和setter相当于下面这样
-
(NSString *)name {
return [_name copy];
} -
(void)setName:(NSString *)name {
[_name release];
_name = [name copy];
}
直接用 @"xxxx" 的就是常量的