2013-02-14 68 views
0

开始下载文件后,如何停止下载文件?我开始这样下载:如何停止在Skydrive API中下载文件

[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"]; 

这是我的代码段,用于下载文件,但不知道如何停止下载文件,一旦启动。

+0

在.NET中这opperation,我会做一个异步下载,并根据要求停止异步线程。我会假设iOS上也有类似的东西。 – 2013-02-14 12:33:02

+0

顺便说一句,在[MSDN文档](http://msdn.microsoft.com/en-us/library/live/hh913536.aspx)中有一个进程调用的委托。也许你可以从该代表中取消? – 2013-02-14 13:28:41

+0

他们没有给出任何方法来取消委托@ @ UweKeim – 2013-02-14 14:52:41

回答

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];

+0

我认为它不工作,因为我只是测试它,什么都没发生? – 2014-03-13 10:03:37