关于不同属性策略对应的setter和getter方法
如果将synthesize省略,并且我们自己实现setter和getter方法时,系统就不会生成对应的setter和getter方法,还有实例变量
1,当把语义特性声明为assign时,setter和getter时方法内部实现
1 - (void)setName:(NSString *)name{2 _name = name;3 }4 - (NSString *)name{5 return _name;6 }
1 - (void)setName:(NSString *)name{2 if (_name != name) {3 [ _name release];4 _name = [name retain];5 }6 }7 - (NSString *)name{8 return [[ _name retain] autorelease];9 }
1 - (void)setName:(NSString *)name{2 if (_name != name) {3 [ _name release];4 _name = [name copy];5 }6 }7 - (NSString *)name{8 return [[ _name retain] autorelease];9 }