/ .h
@property ( strong, nonatomic ) NSString *note;
// .m
@synthesize note = _note;
- ( id ) initWithNote: ( NSString * )note {
self = [ super init ];
if ( self ) {
_note = note; // _note is just a instance variable.
self.note = note; // 'self.note = note;' is using setter method.
return self;
}
return nil;
}
@property ( strong, nonatomic ) NSString *note; 影响setter和getter方法,默认情况下,ARC中变量是 __strong类型。
那么, _note = note; 和 self.note = note; 的区别在哪里?除了strong,非ARC的retain也会有影响。
你看一下这个的使用:
http://www.cnblogs.com/linyawen/archive/2012/06/11/2544482.html