I have the following line in my view controller:
-(void) retrieveAccounts {
accounts = [[NSMutableArray alloc] init];
selAccounts=[[NSMutableArray alloc] init];
NSString *url=[NSString stringWithFormat:@"https://host/accts"];
processor=[[AsynConnectionProcessorController alloc] init];
processor.delegate=self;
processor.server=self.server;
[processor createRequestfromURL:url];
}
The AsynConnectionProcessorController class creates an NSURLConnection to load data from a url in asynchronous mode. It creates a connection in the createRequestfromURL method. Later when page is received comepltely in connectionDidFinishLoading I invoke a processData method on the delegate I set in above snippet. processData updates the tableView and so on.
My question is when I can release the processor variable created above. Should I be calling autorelease. Will the control come to next line of code if I put [processor release] after this line above:
[processor createRequestfromURL:url]
Note: I have a similar question before but this one has more specifics so adding it as a separate question here.
It sounds like you need the processor until the delegate call that does processData. Here’s what I usually do:
connectionProcessor:didProcessData:releaseon the reference passed back in the callback.This way the delegate decides when it’s done with the object.