重複の可能性:
cocoa object-c クラスの変数の前にあるアンダースコアはどのように機能しますか?
self.ivar と ivar の違いは?
アンダースコア プレフィックス付きの合成されたプロパティと変数: これはどういう意味ですか?
オブジェクト c でプロパティを使用するには、2 つの選択肢があります。どちらを使用すればよいでしょうか?
選択 1: self.property = xxxx;
選択肢 2: _property = xxx
例えば:
//.h file
@interface ViewController : UIViewController
@property (retain, nonatomic) NSArray *myArray;
@end
//.m file
@interfaceViewController ()
@end
@implementation ViewController
- (void)doing {
_myArray = [[NSArray alloc] init]; //choice one
self.myArray = [[NSArray alloc] init]; //choice two
}
@end