Reputation: 678
Please clarify, how to deal with returned objects from methods?
Below, I get employee details from GeEmployeetData function with autorelease,
Can I release *emp in Process function?
-(void) Process { Employee *emp = [self GeEmployeetData] }
+(Employee*) GeEmployeetData{
Employee *emp = [[Employee alloc]init]; //fill entity
return [emp autorelease]; }
Upvotes: 3
Views: 331
Reputation: 163238
99% of the time you should retain autoreleased objects returned from other methods if you want to keep them around.
With autoreleased objects, when the pool is drained, the objects in the pool get sent the release
message. That is why 99% of the time you will want to retain autoreleased objects, because the chances of you getting an object with a retainCount
of more than 1
is highly unlikely.
Upvotes: 4