I have a UITableViewController which I’m populating with data from a web service. While the data is downloading I’m using NSInvocationOperation with NSOperationQueue to run the web service call on a background thread while displaying a progress indicator on the UI. This all works fine, but I just want to ensure I’m handling the objects properly. My code is as follows :
NSOperationQueue *backgroundTaskQueue = [[NSOperationQueue alloc] init];
NSInvocationOperation *webServiceOp = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(loadListDataOperation)
object:nil];
[backgroundTaskQueue addOperation:webServiceOp];
[webServiceOp release];
My memory management knowledge tells me I should be releasing backgroundTaskQueue at some point but not sure where – should it just be in the dealloc() method of the UITableViewController?
Any help appreciated,
Jonathan
Yes, you should be releasing the queue if you allocated it. The
deallocmethod would be an ideal place for this.