开发者

Removing NSOperation from queue when view changes

开发者 https://www.devze.com 2022-12-23 22:23 出处:网络
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-serv

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];
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消