2013-02-14 57 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

相關問題