У меня этот код работает на IOS7, его проверка, существует ли изображение на устройстве, а если нет, оно загружается локально.Не удается сохранить изображение локально IOS8
Теперь на IOS8 ничего не спасает, может кто-нибудь мне помочь?
//folder where save
NSString *ImagesPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
// check if image exist
NSString* foofile = [ImagesPath stringByAppendingPathComponent:nombreImagenLocal];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:foofile];
// check if image exist locally
if (!fileExists){
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:rutaCompletaLogo]];
//if not, i save it
if (data) {
// url where is saved
NSString *cachedImagePath = [ImagesPath stringByAppendingPathComponent:nombreImagenLocal];
if ([data writeToFile:cachedImagePath atomically:YES]) {
NSLog(@"Downloaded file saved to: %@", cachedImagePath);
}// end
Используйте 'writeToFile: options: error:' вместо этого и дайте ему указатель NSError. Затем проверьте NSError, чтобы узнать, что случилось. –
Ошибка записи Error Domain = NSCocoaErrorDomain Code = 4 "Операция не может быть выполнена. (Ошибка какао 4.)" UserInfo = 0x7f8170f37710 {NSFilePath =/Пользователи/BEhost/Library/Developer/CoreSimulator/Devices/66E03424-9959-473C -9912-BEAD2BE9C8A4/data/Containers/Data/Application/79C7F75A-7A3C-4C26-88CE-3FC7B3DD12D2/Documents /, NSUserStringVariant = Папка, NSUnderlyingError = 0x7f817315c590 «Операция не может быть выполнена. Нет такого файла или каталога»} –