2011-01-31 39 views
0

在iOS開發使用Core Data框架時,爲什麼在實際設備此行不會工作:這條線爲什麼不能在真正的iOS設備上工作?

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

這是否意味着DB文件是UUID/Documents目錄下?或者它意味着它在UUDI/MyApp.app/Documents下?

回答

1

applicationDocumentsDirectory應指向GUID/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 2011-01-31 03:18:49

相關問題