【问题标题】:How to stop downloading file in Skydrive API如何在 Skydrive API 中停止下载文件
【发布时间】:2014-03-12 17:50:17
【问题描述】:

开始下载文件后,如何停止下载文件?我像这样启动下载:

[docDirSkyDRive  appendString:[NSString stringWithFormat:@"/%@ ",[[FilesFromSkyDrive objectAtIndex:indexPath] objectForKey:@"name"]]];
NSMutableString *downloadPath=[[NSMutableString alloc]init];
[downloadPath appendFormat:@"%@/content",[[FilesFromSkyDrive objectAtIndex:indexPath] objectForKey:@"id"]];
[self.liveClient downloadFromPath:downloadPath delegate:self userState:@"download"];

这是我用于下载文件的代码 sn-p,但不知道如何停止下载文件。

【问题讨论】:

  • 在 .NET 中,我会进行异步下载并根据请求停止异步线程。我认为这样的东西也可以在 iOS 上使用。
  • 顺便说一句,在the MSDN documentation 中有一个在进度时调用的委托。也许您可以从该委托中取消?
  • 他们没有在委托中提供任何取消方法。@UweKeim
  • 是的,我看到了 :-) 抛出异常以退出下载并在调用堆栈中的某个位置捕获它是否至少是一种不好的做法?

标签: objective-c onedrive


【解决方案1】:

尝试这样做

[docDirSkyDRive  appendString:[NSString stringWithFormat:@"/%@ ",[[FilesFromSkyDrive    objectAtIndex:indexPath] objectForKey:@"name"]]];
NSMutableString *downloadPath=[[NSMutableString alloc]init];
[downloadPath appendFormat:@"%@/content",[[FilesFromSkyDrive objectAtIndex:indexPath] objectForKey:@"id"]];
LiveOperation *opperation = [self.liveClient downloadFromPath:downloadPath delegate:self userState:@"download"];

然后你可以使用[opperation cancel];取消这个操作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-22
    • 2019-08-20
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 2012-08-20
    相关资源
    最近更新 更多