Hi, sorry, can't seem to find an answer to this.
What is the convention with retain counts for objects that exist to push something into the runloop later on (such as a scheduled timer or an asynchronous data fetch) which are created through the non-alloc/init routes?
I'm aware that when you do something like:
"string" is in the autorelease pool, so to be treated broadly as though it's a value the stack.
Therefore, if it follows the ordinary conventions then something like:
Will return a timer that isn't guaranteed to fire, since it may be released at any point after execution has gone back to the runloop.
A broadly similar question: what is the correct response when receiving the final delegate callback from an object that I created? Such as, for example, in:
I've been treading cautiously and calling [connection autorelease] (so it'll be released at some point definitely after whatever method it may be in to call me has completed safely), is that the normal thing to do?
What is the convention with retain counts for objects that exist to push something into the runloop later on (such as a scheduled timer or an asynchronous data fetch) which are created through the non-alloc/init routes?
I'm aware that when you do something like:
Code:
NSString *string = [NSString stringWithFormat:@"Some text"];
"string" is in the autorelease pool, so to be treated broadly as though it's a value the stack.
Therefore, if it follows the ordinary conventions then something like:
Code:
NSTimer *timer = [NSTimer scheduledTimerWithInterval:...];
Will return a timer that isn't guaranteed to fire, since it may be released at any point after execution has gone back to the runloop.
A broadly similar question: what is the correct response when receiving the final delegate callback from an object that I created? Such as, for example, in:
Code:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
I've been treading cautiously and calling [connection autorelease] (so it'll be released at some point definitely after whatever method it may be in to call me has completed safely), is that the normal thing to do?