Hi, I am working on an app that will asynchronous to load data. Suppose I have a view controller with a method:
in MyViewController: - (void) loadData { DataHandler *myHandler = [[DataHandler alloc] init]; // set this view controller itself as a delegate, when the data loading finished, myHandler will call its callback method myHandler.delegate = self; [myHandler startAsyncLoading]; } // callback method get called by DataHandler when the data loading is done - (void) myCallback:(id)responseData { // setup the data source to be used later } In the DataHandler class, it will use NSURLConnection to call a webservice to load the data asynchronous. And it has a delegate instance variable which points to the MyViewController, when connectionDidFinishLoading is called, I will do like this: - (void) connectionDidFinishLoading:(NSURLConnection *)connection { // do something [delegate myCallback:self]; // point 1 } My question is, when should I release the myHandler? Should I release it in the myCallback, but after myCallback method finishes, it will return point 1 indicated as above, and that myHandler instance is just released. Or there is a better way to deal with async object? I also wonder how NSURLConnection class handle this itself. Thanks. -- ========================== Life isn't about finding yourself. Life is about creating yourself. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com