I am creating an application which involves so many web-service calls. I am using NSOperation to execute the web-service calls. There are several views in the application and I'm calling the web-service each time the view loads. Since it is navigation, if user decides to go back to the previous view even before the operation gets completed, another operation is getting into the queue and will be waiting for the previou开发者_如何学运维s operation to be completed. Is there any way to stop the previous operation from being executed when its view changes? pls help
Did you try something like this in your view controller:
- (void)viewWillDisappear:(BOOL)animated {
[myOperation cancel];
...
}
精彩评论