NSPersistentStoreCoordinator没有持久存储

时间:2013-02-22 08:13:02

标签: iphone ios objective-c core-data core-data-migration

我正在尝试为我的核心数据库执行轻量级迁移。我已经在我的appdelegate中包含了所有代码,就像在每个教程中所说的那样。然后我有这段代码。

- (void)fetchNewsIntoDocument:(UIManagedDocument *)document
{
    dispatch_queue_t fetchNews = dispatch_queue_create("news fetcher", NULL);
    dispatch_async(fetchNews, ^{
        NSArray *news           = [GenkData getNews];
     [document.managedObjectContext performBlock:^{

        int newsId          = 0;
        for (NSDictionary *genkInfo in news) {
            newsId++;
            [News newsWithGenkInfo:genkInfo inManagedObjectContext:document.managedObjectContext withNewsId:newsId];
            NSLog(@"news inserted");
        }

        [document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL];
       }];
    });
   dispatch_release(fetchNews);

}

但是当我运行它时,它第一次正确运行它,但是当我刷新时我得到了这个错误。

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This NSPersistentStoreCoordinator has no persistent stores.  It cannot perform a save operation.'

有人可以帮我吗?

0 个答案:

没有答案