- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
此 NSPersistentStoreCoordinator 没有持久存储。它无法执行保存操作。
NSInternalInconsistencyException(SIGABRT) This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.
0 CoreFoundation 0x000000018268a59c ___exceptionPreprocess + 132 1 libobjc.A.dylib 0x0000000192dd40e4 objc_exception_throw + 56 2 CoreData 0x000000018240a658 ___65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 5080 3 CoreData 0x0000000182411654 _gutsOfBlockToNSPersistentStoreCoordinatorPerform + 180 4 libdispatch.dylib 0x000000019341936c __dispatch_client_callout + 16 5 libdispatch.dylib 0x00000001934226e8 __dispatch_barrier_sync_f_invoke + 76 6 CoreData 0x0000000182404cb4 __perform + 180 7 CoreData 0x0000000182342c34 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 300 8 CoreData 0x0000000182342c64 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 348 9 CoreData 0x0000000182369400 -[NSManagedObjectContext save:] + 1284 10 RBookReader 0x00000001000109d4 __44-[RCCoreDataManager mocDidSaveNotification:]_block_invoke (RCCoreDataManager.m:186) 11 CoreData 0x00000001823dd270 _developerSubmittedBlockToNSManagedObjectContextPerform + 200 4 libdispatch.dylib 0x000000019341936c __dispatch_client_callout + 16 13 libdispatch.dylib 0x00000001934234c0 __dispatch_queue_drain + 1216 14 libdispatch.dylib 0x000000019341c474 __dispatch_queue_invoke + 132 15 libdispatch.dylib 0x0000000193425224 __dispatch_root_queue_drain + 664 16 libdispatch.dylib 0x000000019342675c __dispatch_worker_thread3 + 108 17 libsystem_pthread.dylib 0x00000001935f52e4 _pthread_wqthread + 812 18 libsystem_pthread.dylib 0x00000001935f4fa8 __pthread_set_self + 12
this is my Code:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (!_persistentStoreCoordinator)
{
self.storeURL =[NSURL fileURLWithPath:[XQDocumentPath() stringByAppendingPathComponent:@"Model.sqlite"] isDirectory:NO];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
nil];
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel];
@try {
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:self.storeURL options:options error:&error]) {
if (error) {
DLog(@"error: %@", error.localizedDescription);
DLog(@"rm \"%@\"", self.storeURL.path);
}
};
}
@catch (NSException *exception) {
DLog(@"addPersistentSoreWithType fail, reason = %@",exception.description);
}
@finally {
}
}
return _persistentStoreCoordinator;
}
#pragma mark
#pragma mark -context save notification
- (void)mocDidSaveNotification:(NSNotification *)noti
{
NSManagedObjectContext *savedContext = [noti object];
// Ignore change notifications for the top MOC.
if (!savedContext.parentContext) {
return;
}
if (!savedContext.persistentStoreCoordinator) {
return;
}
// Ignore changes for other databases.
if (self.privateObjectContext.persistentStoreCoordinator != savedContext.persistentStoreCoordinator) {
return;
}
[savedContext.parentContext performBlock: ^{
NSError *error;
if (savedContext.parentContext.hasChanges) {
@try
{
if (![savedContext.parentContext save: &error]) {
NSLog(@"Error saving context %@: %@", savedContext.parentContext, [error localizedDescription]);
#if defined DEBUG && defined TEST
[self showValidationError:error];
#else
#endif
}
}
@catch(NSException *exception)
{
DLog(@"Unable to perform save: %@", (id)[exception userInfo] ?: (id)[exception reason]);
}
@finally
{
}
}
}];
}
最佳答案
首先,@try/@catch
永远不会触发。 Core Data 不会像 Objective-C 中那样抛出异常。
其次,您的 addPersistentStoreWithType...
似乎失败了,但您的 DLog
(假设它基于我的 DLog
)却保持沉默正在生产中。
因此,我建议如下:
@try/@catch
block ,它们不会执行任何操作DLog
调用至少更改为 ALog
调用,并提供有关商店拒绝添加原因的信息。关于ios - CoreData 很少 'This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34195795/
我最近从 xcode 3.x 更新到 4.2,当我在 4.2 中运行应用程序时,我遇到了核心数据问题。我还更新到了 iOS 5,所以问题可能就在那里,我不太确定。 这些应用程序在 3.x 中运行良好,
我正在开发一个使用 Core Data 的 iPhone 应用程序。该应用程序调用 Web 服务,解析生成的 XML 文件,然后在我的应用程序中创建或修改 Core Data 对象。我已经处理了 We
每次我更改应用程序的核心数据模型时,它都会在下次启动时生成不可恢复的错误:“用于打开商店的模型与用于创建商店的模型不兼容”。 我发现避免这种情况的唯一可靠方法是手动删除应用程序并让 Xcode 重新安
在 iOS 应用程序中,我想将 NSPersistentStoreCoordinator 与 NSIncrementalStore 子类一起使用,用于从 REST API 获取数据,但也与 SQLit
我有一个名为 TestProject 的 xcode4 项目,我正在尝试将 CoreData 添加到其中。我添加了一个包含一些实体的数据模型(名为 TestDataModel),并为这些实体创建了 N
我目前已经为我的 iOS 应用程序的当前版本下载了我的崩溃日志。我看到了一条我无法理解的奇怪消息: [NSPersistentStoreCoordinator(_NSInternalMethods)
我目前正在使用 iCloud 和 CoreData 在我的应用程序中同步数据,因此每次触发通知时,我都会更新我的本地数据数组。我遇到的问题是我的数据集越来越大,我不想每次有新通知时都更新整个数据集。
我正在考虑使用两个 persistent store coordinator,PSC1 将仅读取 一个 sqlite DB,PSC2 将读取和写入 DB。有时 PSC1 会从 DB重新加载内容。 你觉
来自 Stanford 193P 的核心数据讲座iTunes 上的 iPhone 类(class),讲师在不使用 NSPersistentStoreCoordinator 的情况下使用 Core Da
我正在尝试在一个项目上使用 Core Data,该项目的代码改编自 iOS 编程:The Big Nerd Ranch Guide(第三版)。打开 SQLite 文件会导致异常,无论阅读多少文档或挖掘
创建persistentStoreCoordinator时,对addPersistentStoreWithType的调用崩溃。使用 Zombies 进行调试会发现释放错误 -[NSRelationsh
我有一个通过 UIManagedObjectDocument 使用核心数据的应用程序。我正在尝试使用加密核心数据 ( https://github.com/project-imas/encrypted
我知道其他开发者也经常问过这个问题。 我正在使用核心数据。 在上次运行代码时,它工作正常,但今天当我构建并运行应用程序时,我发现了此错误。 由于未捕获的异常“NSInvalidArgumentExce
我刚刚设置了一台使用 Xcode 进行开发的新机器,当我打开、构建并运行一个现有的核心数据项目(它在我的旧机器上仍然运行良好)时,我收到“无法创建 NSPersistentStoreCoordinat
由于我遇到的崩溃,我正试图找到一个官方答案,类似于: nil is not a legal NSPersistentStoreCoordinator for searching for entity
我花了很多时间让我的 Core Data 模型在开发中的 iOS 应用程序中高效工作。在大多数情况下,我的一切工作都很顺利,但前几天我偶然遇到了一个独特的错误加载我的数据。我刚开始在我的 iPhone
我已经用(任务)建立了一个模型,在我理解核心数据的过程中,我做到了这一点:向上下文添加三个项目: NSManagedObjectModel *m = [NSManagedObjectModel mer
我有一个运行完美的 coreData 数据模型文件。由于一些特殊要求,我删除旧的数据模型文件并创建了另一个具有完全相同实体的数据模型文件。与之前的数据模型相比,实体没有变化。我已将其作为不同 bund
我已阅读I keep on getting "save operation failure" after any change on my XCode Data Model 错误代码: This
我正在使用 MagicalRecord, 这就是我设置 coreData 堆栈的方式 - (BOOL)application:(UIApplication *)application didFinis
我是一名优秀的程序员,十分优秀!