// .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;
then有什么区别?而不是strong
,retain
在非 ARC 上在这种情况下有所作为。