【发布时间】:2014-09-02 11:33:23
【问题描述】:
我遇到了许多其他人报告的持久性存储错误。但是,在我的情况下,这不是由于更改了数据库模型。我追了那只兔子几个小时。最后一篇文章引导我尝试删除数据库本身。我去了我的 URL 指向的目录
url=/Users/ccox/Library/Application Support/iPhone Simulator/7.1/Applications/8A231E05-B3A2-4E83-8C81-6B3989C262A5/Library/Documentation/DBEViewDocumentand
它不存在。 url=/Users/ccox/Library/Application Support/iPhone Simulator/7.1/Applications/8A231E05-B3A2-4E83-8C81-6B3989C262A5/Library/
在那里,但文档目录不在那里。
这是我用来获取 URL 的代码
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *documentsDirectory =[[fileManager URLsForDirectory:NSDocumentationDirectory inDomains:NSUserDomainMask] firstObject];
NSString *documentName = @"DBEViewDocument";
self.url = [documentsDirectory URLByAppendingPathComponent:documentName];
self.document = [[UIManagedDocument alloc] initWithFileURL:self.url];
NSLog(@"url=%@",[self.url path]);
NSLog 的输出就是上面的输出 URL。
是否有某个地方可以设置该文档目录的目标位置?显然,文档目录不是标准目录,因为它不是作为应用程序安装的一部分创建的。
我继续创建了文档目录,现在一切正常(至少到目前为止),但我不敢相信这是设计使然,每个人都必须这样做。
有什么想法吗? 谢谢 芯片
【问题讨论】:
标签: ios objective-c url core-data persistent-storage