有没有办法取消AFHTTPRequestOperation?我用它来下载PLIST例如.所以我打算用一个按钮来取消下载或任务.有办法吗?
更新:
operationQueue = [NSOperationQueue new]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.responseSerializer = [AFPropertyListResponseSerializer serializer]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id propertyList) { NSLog(@"DONE"); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"%@", error); } ]; [operationQueue addOperation:operation];
所以我把"操作"放到"operationQueue"并且可以用以下命令停止操作:
[operationQueue cancelAllOperations];
这只是队列中的一个操作.如果有多个,有没有办法明确停止操作?我想在控制台中出现以下错误 - 如果队列被取消,这是正常的吗?
错误域= NSURLErrorDomain代码= -999"无法完成操作.
Aaron Brager.. 12
您可以使用:
[operation cancel];
这是一种由AFNetworking实施的NSOperation方法.
您可以使用:
[operation cancel];
这是一种由AFNetworking实施的NSOperation方法.