Can I create an NSURLConnection object with an asynchronous request in applicationDidFinishLaunching:, and not keep a reference to it in an instance variable, as follows?
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSURLConnection *localVariable = [[NSURLConnection alloc] initWithRequest:req delegate:self];
}
I believe this should work when not using ARC. While I no longer have any reference to the NSURLConnection object, it should do its job and not get deallocated until I release it in one of its delegate methods, like connectionDidFinishLoading:, because it leaves applicationDidFinishLaunching: with a retain count of +1, right?
The question, however, is: Is this considered bad style? Should I always maintain an instance variable with this kind of object relationship? What would I do to make this work with ARC? After all, when localVariable goes out of scope, ARC would deallocate my NSURLConnection, I suppose.