标签:copy nat name setname void setter ase nss string
写一个 setter 方法用于完成 @property (nonatomic, retain) NSString *name
写一个 setter 方法用于完成 @property (nonatomic, copy) NSString *name
答:
// retain
- (void)setName:(NSString *)str {
[str retain];
[_name release];
_name = str;
}
// copy
- (void)setName:(NSString *)str {
id t = [str copy];
[_name release];
_name = t;
}
写一个 setter 方法用于完成 @property (nonatomic, retain) NSString *name,
标签:copy nat name setname void setter ase nss string
原文地址:https://www.cnblogs.com/huangzs/p/10622508.html