시작하기 전에 문서 디렉토리를 다루는 모든 게시물을 살펴 보았습니다.iOS 5.1 Simulator "Documents"고스트 디렉토리
그래서 나는 당신이 나를 도울 수 있도록 내 문제를 분열 시키려고 노력할 것입니다.
5.1 용 iOS 애플리케이션을 개발 중입니다. 나는 XCode 4.4.1과 iOS 시뮬레이터 버전 5.1 (272.21)을 사용하고있다.
이 응용 프로그램은 시뮬레이터에 설치되어있는 경우, 그 디렉토리 구조는
내 응용 프로그램을 실행할 때이 제대로 반영/Library/Application Support/iPhone Simulator/[IOS_VERSION]/Applications/[APP_UUID]
에서 매핑되는 것을 나의 이해이다.
또한 나는 성공적으로 만들고 다음 경로에 결과를 다음 코드
NSString *tmpDir = NSTemporaryDirectory();
를 사용하여 임시 디렉토리를 사용할 수 있어요
/Library/Application Support/iPhone Simulator/[IOS_VERSION]/Applications/[APP_UUID]/tmp
문제는 내가 작업 할 때 나타나는 시작
/Library/Application Support/iPhone Simulator/[IOS_VERSION]/Applications/[APP_UUID]/Documents
로되어있는 문서 디렉터리
다음 코드는 해당 경로의 존재 여부를 확인한 다음 NSLog를 사용하여 경로를 기록합니다.이 경로가 존재한다고 말하더라도 해당 위치로 파일을 찾을 수 없습니다. 결과는 NSLog 라인이다
+ (NSString *) currentPath{
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [searchPaths objectAtIndex:0];
searchPaths=nil;
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:documentPath];
if (fileExists == TRUE) {
NSLog(@" %@ already exists",documentPath);
} else {
NSLog(@"doesn't exists");
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
if(![fileManager createDirectoryAtPath:documentPath withIntermediateDirectories:true attributes:nil error:&error])
{
NSLog(@"Couldn't create documents directory %@",error);
}
}
return documentPath;
}
은 다음과 같습니다 터미널
> pwd
/Users/fotis/Library/Application Support/iPhone Simulator/5.1/Applications/7CE8645A-BDD7-4AB6-8CAB-B0EF1579CD2B
>ls -lsa
total 0
0 drwxr-xr-x 5 fotis 170 Aug 9 23:12 .
0 drwxr-xr-x 3 fotis 102 Aug 9 22:50 ..
0 drwxr-xr-x 30 fotis 1020 Aug 9 23:12 AMM.app
0 drwxr-xr-x 4 fotis 136 Aug 9 22:50 Library
0 drwxr-xr-x 4 fotis 136 Aug 9 22:51 tmp
당신이 볼 수 있듯이에서
2012-08-09 23:12:09.813 AMM[22656:c07] /Users/fotis/Library/Application Support/iPhone Simulator/5.1/Applications/7CE8645A-BDD7-4AB6-8CAB-B0EF1579CD2B/Documents already exists
, 내 문서 유령 디렉토리가 없다. 내 삶에 대해 나는 그 모든 것의 뒤에있는 마법을 이해할 수 없다. 한 가지주의해야 할 것은 내가 거기에서 초기화를하고 있기 때문에, "- didFinishLaunchingWithOptions"메쏘드 델리게이트에서 이것을 실행하고 있다는 것입니다.
아이디어가 있으십니까?