0

我试图检查 /var/mobile/Documents/ 中是否存在文件,并且它在非 arm64 的设备上完美运行。但是当我在 arm64 设备上尝试它时,它给了我可可错误 257。

我在 ipad3/4 和 ipod5 上试过,它工作。但是当我在 ipad mini 2 和 iPhone5S 上尝试时,它们都给了我可可错误 257。

我快速检查了文件是否可读,我在 ipad3/4 和 ipod5 上得到“是”,但在 ipad mini 2 和 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];
}

任何帮助,将不胜感激!

4

1 回答 1

1
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];
}
于 2014-03-29T18:37:23.797 回答