2012-10-06 96 views
0

我使用ASI下載文件。 但它只適用於如果我將路徑設置爲NSDocumentDirectory爲什麼我只能在NSDocumentDirectory保存文件或創建文件夾

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *cachesDirectory = [paths objectAtIndex:0]; 

我並沒有改變任何其他代碼,只需更換NSDocumentDirectoryNSCachesDirectoryNSDownloadsDirectory,它不工作。

下載進度是100%,文件沒有保存。

我不知道爲什麼。

回答

1

此代碼:

[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] 

完美的作品在我的許多項目。我認爲問題出在您的保存代碼中。你能證明嗎?

+0

無法正常工作 – 2012-10-31 07:44:35

-2

你可以做得更容易,並寫信給任何位置。 如果您使用的是ASI,則可以下載DATA。 (NSData) 所以:

NSFileManager *fileMgr = [NSFileManager defaultManager]; 
[fileMgr createFileAtPath:@"whateverpathyouwant" contents:downloaddata attributes:nil]; 

這隻能如果你是jailbroken我猜。

相關問題