ios - Objective C: Query about releasing instance property -
i have general query regarding memory management
//in .h file defined property @interface aclass { someclass *aproperty; } @property (nonatomic, retain) someclass *aproperty; end //in .m file synthesized property , initialized property @implementation aclass -(void)amethod { self.aproperty = [[someclass alloc]init]; }
my question
for 'aproperty', do 'release' prevent memory leak? understand instance properties (using dot notations), release in 'dealloc' , 'viewdidunload' methods. instance, need release aproperty again within method 'amethod'?
- you must release instance in dealloc
- your property initializations leaks memory. alloc+init, retain inside property, don't release.
self.property = [[[someclass alloc] init] autorelease]
used.
Comments
Post a Comment