2014-03-29 2 views
0

에 대한 경로를 찾을 수 없습니다. 파일이/var/mobile/Documents /에 있는지 확인하려고 시도 중이므로 arm64가 아닌 장치에서 완벽하게 작동합니다. 하지만 arm64 장치에서 시도하면 코코아 오류 257이 발생합니다.NSFileManager에서/var/mobile/

나는 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]; 
} 

어떤 도움을 받으실 수 있나요?

+0

'/ var/mobile'에 대해 동일한 호출을하면 어떻게됩니까? – mharper

+0

@mharper 똑같은 일이 발생하고,/var /를 호출하면 모두 작동하는 것처럼 보이지만,/var/mobile/또는 mobile 내부의 모든 것을 호출하면 arm64에서 작업을 멈 춥니 다. – Mike

+0

@ igor의 대답을 참조하십시오. NSSearchPathForDirectoriesInDomains는 아키텍처에 따라 다른 경로를 반환해야합니다. – mharper

답변

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]; 
} 
+0

감사! 이것은 그것을 한 것으로 보인다. – Mike