0
可能重複:
iVar property, access via self?使用getter的sythesize屬性或直接訪問對象有什麼區別嗎?
據我所知,這是使用實例變量的制定者,但療法使用的直接訪問干將istead任何原因?
.
.
NSArray *instArray;
.
.
@property (nonatomic, retain)NSArray *instArray;
.
.
@synthesize instArray;
.
.
//are the following lines equal?
NSArray *array = [NSArray arrayWithArray:self.instArray];
NSArray *array = [NSArray arrayWithArray:instArray];
另請參閱:http://stackoverflow.com/questions/2914399/does-it-make-a-difference-in-performance-if-i-use-self-foobar-instead-of-foobar http:/ /stackoverflow.com/questions/4271657/when-to-access-properties-with-self http://stackoverflow.com/questions/3494157/in-objective-c-on-ios-what-is-the-style-差異之間的自我foo-and-foo http://stackoverflow.com/questions/3318499/ivars-with-and-without-self –
謝謝你的上述鏈接,他們都對我有用。 – Michael
很高興你發現他們有幫助! –