这条线为什么不能在真正的iOS设备上工作?

问题描述:

在iOS开发使用Core Data框架时,为什么在实际设备此行不会工作:这条线为什么不能在真正的iOS设备上工作?

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

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

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