Question

Im trying to check if a file exists at /var/mobile/Documents/ and it works perfectly on devices that aren't arm64. But when I try it on an arm64 device it's giving me cocoa error 257.

I tried on ipad3/4 and ipod5 and it worked. But when I tried it on both ipad mini 2 and iPhone5S they both gave me cocoa error 257.

I did a quick check to see if the file is readable and I get YES on ipad3/4 and ipod5 but I get NO on ipad mini 2 and 5S.

if ([[NSFileManager defaultManager] isReadableFileAtPath:@"/var/mobile/Documents/"]  == YES) {
          UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"yes" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
          [al show];
} else {
           UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"no" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
           [al show];
}

Any help would be appreciated!

Was it helpful?

Solution

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = paths[0];

if([[NSFileManager defaultManager] isReadableFileAtPath:documentsDirectoryPath]) {
    UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"yes"
                                                 message:nil
                                                delegate:self
                                       cancelButtonTitle:@"Ok"
                                       otherButtonTitles:nil, nil];
    [al show];
}
else {
    UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"no"
                                                 message:nil
                                                delegate:self
                                       cancelButtonTitle:@"Ok"
                                       otherButtonTitles:nil, nil];
    [al show];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top