写一个 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;
}
原文地址:https://www.cnblogs.com/huangzs/p/10622508.html
时间: 2024-10-10 06:13:16