I have a HTTP request in Navigation Controller by:
[[RKClient sharedClient] get:url delegate:self];
But if user presses the back button when the request is still running, the app crashed:
*** -[UITableView retain]: message sent to deallocated instance 0xeab5600
I added the following code in viewWillUnload (and viewDidUnload) to cancel the request, but got the same error:
[[RKClient sharedClient].requestQueue cancelRequestsWithDelegate:self];
Please help. Thanks.
I found out that when the view is being popped from navigation controller, viewDidUnload and viewWillUnload did not be triggered. So I moved the cancelRequestsWithDelegate method to viewWillDisappear to solve the problem.