// .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
、retain
非 ARC でこの状況に違いをもたらします。