以下是代码:
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}