Box IOS SDK V2取消下载/上载操作
我使用objective-CBoxSDK使用专用方法管理文件Box IOS SDK V2取消下载/上载操作,ios,box-api,boxapiv2,Ios,Box Api,Boxapiv2,我使用objective-CBoxSDK使用专用方法管理文件 [[BoxSDK sharedSDK].filesManager downloadFileWithID:fileID outputStream:outputStream requestBuilder:nil
[[BoxSDK sharedSDK].filesManager downloadFileWithID:fileID
outputStream:outputStream
requestBuilder:nil
success:successBlock
failure:failureBlock
progress:progressBlock];
我需要能够取消下载任务,但我无法找到一种方法来做到这一点!
我还需要能够取消上传任务,但我想这样做的方式将是相同的
有人做到了吗?文件管理器返回BoxAPIDataOperation。 BoxAPIDataOperation最终继承自NSOperation和Box基类,因为它是BoxAPIOperation。 要取消BoxAPIOperation,只需向其发送一条消息cancel 事实上,BoxSDK中的所有资源管理器都返回从BoxAPI操作继承的类。 您可以在BoxAPIOperation.m中找到(void)cancel 所以在你的情况下,你会想要这样的东西
// property to store pointer to currently active download operation.
// it is weak, because you don't want to retain it. after download is completed, cancelled or failed
@property (nonatomic, readwrite, weak) BoxAPIDataOperation *downloadOperation;
....
self.downloadOperation = [[BoxSDK sharedSDK].filesManager downloadFileWithID:fileID
outputStream:outputStream
requestBuilder:nil
success:successBlock
failure:failureBlock
progress:progressBlock];
...
- (void)dealloc
{
[self.downloadOperation cancel];
}
// only if want to keep self in object and want to just cancel operation
- (void)userPressedCancelButton:(id)sender
{
[self.downloadOperation cancel];
}
真不敢相信我错过了!非常感谢你!在寻找如何做到这一点时,我找到了这个类的cancel方法,但由于它没有在.h文件中声明,我认为它只供内部使用…这非常有用,但还有一件事我想实现暂停/恢复收件箱文件下载。运气好吗/