I have got some questions about autorelease feature.
Please advice..
Q1) Does it have a any sense or value about calling retain or release to autoreleased object?
ex1)
UIView *viewTest = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)] autorelease];
[self.view addSubview:viewTest];
In this condition, viewtest object will be released in future?
Or need to add a line ‘[viewTest release];’?
ex2)
UIView *viewTest = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)] autorelease];
[viewTest release];
In this case, viewTest will be autorelease?
Q2) Where does autoreleased object be destroyed?
Not really, the object will get released when the autoreleasepool is drained anyway. Take a look at this
The autoreleased object is destroyed when the
NSAutoreleasePoolis drained, or at the end of the@autoreleasepoolconstruct, which basically does the same thing.