I am trying to read a file in which I successfully downloaded and saved in the Documents directory. However, when I try to read it, if fails.
Here is the error:
2016-03-28 21:00:26.585 App[569:4103] Path is /var/mobile/Applications/3AFA2430-C0DC-44CD-95F8-A89D82B2C348/Documents/combo.bin 2016-03-28 21:00:26.603 App[569:4103] Error in reading Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x17df29d0 {NSFilePath=/var/mobile/Applications/3AFA2430-C0DC-44CD-95F8-A89D82B2C348/Documents/combo.bin, NSUnderlyingError=0x17df90b0 "The operation couldn’t be completed. Permission denied"} Here is my code:
NSError *error; NSData *firmwareContentData = [NSData dataWithContentsOfFile:FIRMWARE_LOCAL_PATH options:NSDataReadingMappedIfSafe error:&error]; NSLog(@"Path is %@", FIRMWARE_LOCAL_PATH); if(error) { NSLog(@"Error in reading %@", error); return; } local path is
#define FIRMWARE_LOCAL_PATH [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"combo.bin"] I tried using NSTemporaryDirectory(), using NSFileManager to get the contents of the file, but none of them works. Any idea why? Thanks in advance!