【发布时间】:2013-02-06 19:01:00
【问题描述】:
以下是代码:
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
[imageData writeToFile:savedImagePath options:NSDataWritingAtomic error:&error];
if(error != nil)
NSLog(@"write error %@", error);
错误:
write error Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x8b7b850 {NSUnderlyingError=0x8b7d7c0 "The operation couldn’t be completed. No such file or directory", NSFilePath=/Users/alfa-1/Library/Application Support/iPhone Simulator/6.0/Applications/C24B228A-599E-4249-97A7-17775E8A546B/Library/Caches/ChannelListImages/http:/direct.domain.com/files/icons/1-all-cb.jpg, NSUserStringVariant=Folder}
【问题讨论】:
-
也许你必须创建中间文件夹...
-
在 NSLog 中显示你的 savedImagePath。路径可能无效
-
什么是中间文件夹?
-
如果路径是 /folderA/folderB/folderC。 folderA 和 folderB 将是中间文件夹。如果要保存在文件夹C文件夹A中,B和C必须存在才能保存。
-
@MohammedEbrahim 什么是 savedImagePath?
标签: ios nsdata writetofile