when I use [[NSFileManager defaultManager] createFileAtPath:filePath contents:imageData attributes:nil] store image data, in some case this method return failed.I really don't know why. And the path is right,just like '/var/mobile/Containers/Data/Application/XXXXXXXX-XXXX-XXXX-XXXX-8A642743A991/Library/Caches/com.hackemist.SDWebImageCache.default/c513458d06b63d4561e39f77269e520d'. And I find in the same path,invoke [data writeToFile:filePath options:0 error:&error] work well, no error. Can someone tell me some of the reasons?
createFileAtPath with imageData failed
I’d say “What error does it return?” but that method doesn’t return errors. Which speaks to a more general issue. The path-based APIs in Foundation are old and we generally recommend that you use the URL-based ones. Those return errors when they fail. So, rather than calling -[NSFileManager createFileAtPath:contents:attributes:]
I recommend that you call -[NSData writeToURL:options:error:]
. And if that continues to fail, you’ll get a error that should help you understand why.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"