首页 > 其他 > 详细

coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores.

时间:2015-01-05 14:43:04      阅读:796      评论:0      收藏:0      [点我收藏+]

最近在修改一个程序BUG的时候遇到一个问题coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores.

但实际跑程序时。增删保存都没问题。

我花了很多的时间在问题抛出的地方在[contextsave:&error]; 

后来发现,早在初期化_persistentStoreCoordinator 时就报错了

 

    if (![_persistentStoreCoordinator

         addPersistentStoreWithType:NSSQLiteStoreType

         configuration:nil

          URL:storeUrl

          options:nil

          error:&error]) {

       // Handle the error.

    } 

 

&error 显示的信息为The model used to open the store is incompatible with the one used to create

上网搜了下,大意是说可能在改变entities的atrributes时损坏了存储文件。直接把存储文件删除即可。

我试了下,果然就ok了。

另外两个人和我的现象是一样的,不过在storeUrl指定的地方根本没有文件夹,别说文件了。按照storeUrl

的路径把文件夹建好,也就ok了。

我还有个疑问,为什么实际跑画面的时候是好的。只有单体测试的时候有问题?

我又在跑画面的时候,跟进去看了下。实际跑画面的storeUrl的根路径与单体时不同,有一串看似是UUID的随机数。

估计是跑画面的时候有建新目录的权限。

而跑单体的时候既没有建目录权限,也没有删文件权限。所以当存储改变时会报错。

coreData部分报错:This NSPersistentStoreCoordinator has no persistent stores.

原文:http://www.cnblogs.com/limicheng/p/4203427.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!