2011-01-31 2 views
0

코어 데이터 프레임 워크를 사용할 때 iOS 개발에서 실제 장치에서이 행이 작동하지 않는 이유는 무엇입니까?이 라인이 실제 iOS 기기에서 작동하지 않는 이유는 무엇입니까?

NSURL *storeUrl = [NSURL fileURLWithPath: 
        [[self applicationDocumentsDirectory] 
         stringByAppendingPathComponent: @”MyDB.sqlite”]]; 

이것은 DB 파일이 UUID/Documents 디렉토리에 있다는 것을 의미하지 않습니까? 또는 UUDI/MyApp.app/Documents 아래에 있음을 의미합니까?

답변

1

applicationDocumentsDirectoryGUID/YourApp/Documents

를 가리키는해야이 문서 디렉토리

+(NSString *)applicationDocumentsDirectory { 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; 
    return basePath; 
} 

applicationDocumentsDirectory 코드는 무엇을 얻을 수있는 올바른 사용법 것입니까? Apple이나 다른 신뢰할 수있는 출처에서 예제로 사용한다고 가정하면, 이것은 애플 리케이션 Documents 폴더를 가리켜 야합니다.

enter image description here

+0

@WrightsCS 그리고 메소드 이름은 약간 오해의 소지 권리인가? applicationDocumentsDirectory라는 이름입니다. – Chiron

+0

코드가 작동하려면 MyDB.sqlite가 Documents 디렉토리의 루트에 있어야합니다. – WrightsCS

+1

@ 4bu3li 오해의 소지가있는 부분은 무엇입니까? * 응용 프로그램 * 응용 프로그램 번들에는 .app 번들 내에 Documents 디렉토리가 없습니다. 그건 말이 안돼. 이 메서드는 내부에 포함 된 것이 아니라 응용 프로그램과 연결된 Documents 디렉터리를 반환하기 때문에 이름이 지정됩니다. –

관련 문제