写一个setter方法用于完成@property (nonatomic,retain)NSString *name,写一个setter方法用于完成@property(nonatomic,copy)NSString *name
答:
- (void)setName:(NSString*)str {
if (_name != str) {
[_name release];
_name = [str retain];
}
}
- (void)setName:(NSString *)str {
if (_name != str) {
[_name release];
_name = [str copy];
}
}
- (void)setName:(NSString*)str {
if (_name != str) {
[_name release];
_name = [str retain];
}
}
- (void)setName:(NSString *)str {
if (_name != str) {
[_name release];
_name = [str copy];
}
}