iphone - Releasing ivars in Objective-C -


ok, looking @ this:

apple docs: declared properties

if scroll down dealloc reads:

"typically in dealloc method should release object instance variables directly (rather invoking set accessor , passing nil parameter), illustrated in example:"

- (void)dealloc {     [property release];     [super dealloc]; } 

"if using modern runtime , synthesizing instance variable, however, cannot access instance variable directly, must invoke accessor method:"

- (void)dealloc {     [self setproperty:nil];     [super dealloc]; } 

now, must own @ least 15 20 books on ios development. can't have ever seen code in these books proposing 1 other than:

[someproperty release]; 

is there compelling reason edit bunch of files of code works adopt apple's recommendation? how future work? or, pretty equivalent?

apple's document appears apply if have synthesize-by-default turned on. if have turned off, seems default case, need @synthesize, gives access variables directly.

personally, do:

@synthesize someproperty=_someproperty; 

just can do:

- (void)dealloc {   [_someproperty release];   [super dealloc]; } 

see jeff lamarche's blog more.


Comments