문서 폴더에 파일이 있는지 확인하는 데 문제가 있습니다. NSKeyedArchiver가있는 파일에 데이터를 저장하지 않은 경우에도 내 테스트는 true를 반환합니다. 테스트 :iPhone - 데이터 저장 및 검색
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentPath = [documentsDirectory stringByAppendingPathComponent:@"gameData.dat"];
if ([fileManager fileExistsAtPath:documentPath]) {
//if the file exists retrieve the data.
//this is always called, even if there is no file at the documentPath.
}else{
//set the defaults and save data.
}
한 번 명확한 documentPath 시뮬레이터에서 .. – ajay