使用coredata导致的版本更新后程序crash的问题
2011-11-15 10:50
495 查看
在错误收集中有这么一个问题:我使用的xmpp框架,在调整为适应ios5的版本后出现一个导致程序crash问题。但是原来的xmpp代码没有改变,那么问题在哪呢?
报错如下:
在stackoverflow找到解决办法:http://stackoverflow.com/questions/1091228/i-keep-on-getting-save-operation-failure-after-any-change-on-my-xcode-data-mod
需要修改coredata的persistentstorecoordinator的代理实现方法,添加options,使得当coredata数据模型发生变化时,自动更该合并变化。代码如下:
至于已发布的新版本,如果用户遇到该问题。建议推荐用户删除原来的app后,全新安装app程序,即可解决该问题
报错如下:
BUG监听报告: 手机型号: iPhone OS , 版本: 4.1 程序名称: Dating, 版本:1.8 用户: 10892386 2011-11-13 16:17:31.506 Taonan[11747:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.' *** Call stack at first throw: ( 0 CoreFoundation 0x344aaed3 __exceptionPreprocess + 114 1 libobjc.A.dylib 0x33975811 objc_exception_throw + 24 2 CoreData 0x338f29c1 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 196 3 CoreData 0x3389253d -[NSManagedObjectContext save:] + 700 4 Taonan 0x00045145 -[XMPPCapabilitiesCoreDataStorage setCapabilities:forHash:algorithm:] + 444 5 Taonan 0x00042121 -[XMPPCapabilities xmppStream:willSendPresence:] + 232 6 Taonan 0x0003ca57 -[XMPPStream sendElement:withTag:] + 342 7 Taonan 0x0003c8f5 -[XMPPStream sendElement:] + 28 8 Taonan 0x0004592f -[iPhoneXMPP goOnline] + 54
在stackoverflow找到解决办法:http://stackoverflow.com/questions/1091228/i-keep-on-getting-save-operation-failure-after-any-change-on-my-xcode-data-mod
需要修改coredata的persistentstorecoordinator的代理实现方法,添加options,使得当coredata数据模型发生变化时,自动更该合并变化。代码如下:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"database.sqlite"]]; NSError *error = nil; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) { // Handle error } return persistentStoreCoordinator; }
至于已发布的新版本,如果用户遇到该问题。建议推荐用户删除原来的app后,全新安装app程序,即可解决该问题
相关文章推荐
- 使用coredata导致的版本更新后程序crash的问题
- 使用coredata导致的版本更新后程序crash的问题
- 使用coredata导致的版本更新后程序crash的问题
- 使用coredata导致的版本更新后程序crash的问题
- 使用std::sort()排序导致程序core问题分析
- 使用std::sort()排序导致程序core问题分析
- 使用std::sort()排序导致程序core问题分析
- 规避QT4.8.5版本下ocx(dll的情况下)使用QNetworkAccessManager导致程序退出时产生的崩溃问题
- 使用std::sort()排序导致程序core问题分析
- CoreData的使用/以及coreData中的多线程问题/版本迁移(二)
- Protobuf使用不当导致的程序内存上涨问题
- android studio 更新版本后,最新版对sdk文件夹文件目录做了调整,导致eclipse无法使用,建议分开2份sdk。
- Protobuf使用不当导致的程序内存上涨问题
- 16.12.21小程序0.11.122100版本更新问题
- 问题:无法通过Windows installer服务安装此安装程序包。您必须安装带有更新版本windows Installer服务的Windows。
- 微信小程序 122100版本更新问题解决方案
- OpenCV findContours导致程序崩溃和相关使用问题
- CoreLocation 的基本使用 以及定位 指南针的实现 (附加: 系统版本适配的方法,和后台更新用户位置的方法及注意)
- 强制IE使用最高版本引擎渲染页面,避免默认使用IE7引擎导致的页面布局混乱及其它问题
- 关于不使用appStore版本更新的问题