`
kerlubasola
  • 浏览: 709683 次
文章分类
社区版块
存档分类
最新评论

Core Data结构修改后,在AppStore中更新升级crash的问题.

 
阅读更多

问题描述:

在苹果的错误收集中有这么一个问题:

使用的xmpp框架,在调整为适应ios5的版本后出现一个导致程序crash问题。但是原来的xmpp代码没有改变,那么问题在哪呢?

报错如下:

  1. BUG监听报告:
  2. 手机型号:iPhoneOS,版本: 4.3
  3. 程序名称:xxx,版本:1.3
  4. 用户:xxx
  5. 2011-11-1316:17:31.506 [11747:307]***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'ThisNSPersistentStoreCoordinatorhasnopersistentstores.Itcannotperformasaveoperation.'
  6. ***Callstackatfirstthrow:
  7. (
  8. 0CoreFoundation0x344aaed3__exceptionPreprocess+114
  9. 1libobjc.A.dylib0x33975811objc_exception_throw+24
  10. 2CoreData0x338f29c1-[NSPersistentStoreCoordinatorexecuteRequest:withContext:error:]+196
  11. 3CoreData0x3389253d-[NSManagedObjectContextsave:]+700
  12. 4 0x00045145-[XMPPCapabilitiesCoreDataStoragesetCapabilities:forHash:algorithm:]+444
  13. 5 0x00042121-[XMPPCapabilitiesxmppStream:willSendPresence:]+232
  14. 6 0x0003ca57-[XMPPStreamsendElement:withTag:]+342
  15. 7 0x0003c8f5-[XMPPStreamsendElement:]+28
  16. 8 0x0004592f-[iPhoneXMPPgoOnline]+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数据模型发生变化时,自动更该合并变化。

代码如下:

  1. -(NSPersistentStoreCoordinator*)persistentStoreCoordinator{
  2. if(persistentStoreCoordinator!=nil){
  3. returnpersistentStoreCoordinator;
  4. }
  5. NSURL*storeUrl=[NSURLfileURLWithPath:[[selfapplicationDocumentsDirectory]stringByAppendingPathComponent:@"database.sqlite"]];
  6. NSError*error=nil;
  7. NSDictionary*options=[NSDictionarydictionaryWithObjectsAndKeys:
  8. [NSNumbernumberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption,
  9. [NSNumbernumberWithBool:YES],NSInferMappingModelAutomaticallyOption,nil];
  10. persistentStoreCoordinator=[[NSPersistentStoreCoordinatoralloc]initWithManagedObjectModel:[selfmanagedObjectModel]];
  11. if(![persistentStoreCoordinatoraddPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:storeUrloptions:optionserror:&error]){
  12. //Handleerror
  13. }
  14. returnpersistentStoreCoordinator;
  15. }


问题描述:

在苹果的错误收集中有这么一个问题:

使用的xmpp框架,在调整为适应ios5的版本后出现一个导致程序crash问题。但是原来的xmpp代码没有改变,那么问题在哪呢?

报错如下:

  1. BUG监听报告:
  2. 手机型号:iPhoneOS,版本: 4.3
  3. 程序名称:xxx,版本:1.3
  4. 用户:xxx
  5. 2011-11-1316:17:31.506 [11747:307]***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'ThisNSPersistentStoreCoordinatorhasnopersistentstores.Itcannotperformasaveoperation.'
  6. ***Callstackatfirstthrow:
  7. (
  8. 0CoreFoundation0x344aaed3__exceptionPreprocess+114
  9. 1libobjc.A.dylib0x33975811objc_exception_throw+24
  10. 2CoreData0x338f29c1-[NSPersistentStoreCoordinatorexecuteRequest:withContext:error:]+196
  11. 3CoreData0x3389253d-[NSManagedObjectContextsave:]+700
  12. 4 0x00045145-[XMPPCapabilitiesCoreDataStoragesetCapabilities:forHash:algorithm:]+444
  13. 5 0x00042121-[XMPPCapabilitiesxmppStream:willSendPresence:]+232
  14. 6 0x0003ca57-[XMPPStreamsendElement:withTag:]+342
  15. 7 0x0003c8f5-[XMPPStreamsendElement:]+28
  16. 8 0x0004592f-[iPhoneXMPPgoOnline]+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数据模型发生变化时,自动更该合并变化。

代码如下:

  1. -(NSPersistentStoreCoordinator*)persistentStoreCoordinator{
  2. if(persistentStoreCoordinator!=nil){
  3. returnpersistentStoreCoordinator;
  4. }
  5. NSURL*storeUrl=[NSURLfileURLWithPath:[[selfapplicationDocumentsDirectory]stringByAppendingPathComponent:@"database.sqlite"]];
  6. NSError*error=nil;
  7. NSDictionary*options=[NSDictionarydictionaryWithObjectsAndKeys:
  8. [NSNumbernumberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption,
  9. [NSNumbernumberWithBool:YES],NSInferMappingModelAutomaticallyOption,nil];
  10. persistentStoreCoordinator=[[NSPersistentStoreCoordinatoralloc]initWithManagedObjectModel:[selfmanagedObjectModel]];
  11. if(![persistentStoreCoordinatoraddPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:storeUrloptions:optionserror:&error]){
  12. //Handleerror
  13. }
  14. returnpersistentStoreCoordinator;
  15. }

问题描述:

在苹果的错误收集中有这么一个问题:

使用的xmpp框架,在调整为适应ios5的版本后出现一个导致程序crash问题。但是原来的xmpp代码没有改变,那么问题在哪呢?

报错如下:

  1. BUG监听报告:
  2. 手机型号:iPhoneOS,版本: 4.3
  3. 程序名称:xxx,版本:1.3
  4. 用户:xxx
  5. 2011-11-1316:17:31.506 [11747:307]***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'ThisNSPersistentStoreCoordinatorhasnopersistentstores.Itcannotperformasaveoperation.'
  6. ***Callstackatfirstthrow:
  7. (
  8. 0CoreFoundation0x344aaed3__exceptionPreprocess+114
  9. 1libobjc.A.dylib0x33975811objc_exception_throw+24
  10. 2CoreData0x338f29c1-[NSPersistentStoreCoordinatorexecuteRequest:withContext:error:]+196
  11. 3CoreData0x3389253d-[NSManagedObjectContextsave:]+700
  12. 4 0x00045145-[XMPPCapabilitiesCoreDataStoragesetCapabilities:forHash:algorithm:]+444
  13. 5 0x00042121-[XMPPCapabilitiesxmppStream:willSendPresence:]+232
  14. 6 0x0003ca57-[XMPPStreamsendElement:withTag:]+342
  15. 7 0x0003c8f5-[XMPPStreamsendElement:]+28
  16. 8 0x0004592f-[iPhoneXMPPgoOnline]+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数据模型发生变化时,自动更该合并变化。

代码如下:

  1. -(NSPersistentStoreCoordinator*)persistentStoreCoordinator{
  2. if(persistentStoreCoordinator!=nil){
  3. returnpersistentStoreCoordinator;
  4. }
  5. NSURL*storeUrl=[NSURLfileURLWithPath:[[selfapplicationDocumentsDirectory]stringByAppendingPathComponent:@"database.sqlite"]];
  6. NSError*error=nil;
  7. NSDictionary*options=[NSDictionarydictionaryWithObjectsAndKeys:
  8. [NSNumbernumberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption,
  9. [NSNumbernumberWithBool:YES],NSInferMappingModelAutomaticallyOption,nil];
  10. persistentStoreCoordinator=[[NSPersistentStoreCoordinatoralloc]initWithManagedObjectModel:[selfmanagedObjectModel]];
  11. if(![persistentStoreCoordinatoraddPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:storeUrloptions:optionserror:&error]){
  12. //Handleerror
  13. }
  14. returnpersistentStoreCoordinator;
  15. }

分享到:
评论

相关推荐

    AppStore掘金iPhone SDK应用程序开发

    本书旨在帮助开发者在Apple的AppStore中找到成功的路径,通过掌握iPhone SDK的关键技术和最佳实践,实现创新与盈利。 首先,iPhone SDK是苹果公司为开发者提供的一个强大的工具集,它包含了开发iOS应用所需的一切,...

    appstore:Appstore应用程序,半成品..

    标题中的“appstore:Appstore应用程序,半成品..”表明这是一个关于开发苹果App Store应用程序的项目,但只完成了部分工作。描述中提到的背景是在2012年,开发者因为兴趣转移和英语能力不足,导致在开发过程中遇到了...

    iOS开发指南:从零基础到App Store上架

    同时,App Store Connect是发布应用的平台,需要在这里创建开发者账号,提交应用审核,发布更新,并管理应用的元数据和销售统计。 最后,为了使应用能在App Store上架,开发者需要了解Apple的审核指南和App Store...

    iOS开发指南 从Hello World到App Store上架 第4版

    《iOS开发指南:从Hello World到App Store上架 第4版》是一本全面介绍iOS应用开发的书籍,旨在帮助开发者从零基础开始,逐步掌握创建iOS应用并将其发布到App Store的所有步骤。作为第四版,它反映了最新的iOS开发...

    Wrox.iPhone.and.iPad.App.24-Hour.Trainer.2012

    《Wrox.iPhone.and.iPad.App.24-Hour.Trainer.2012》是一部专为iOS开发者设计的详细教程,旨在帮助读者在24小时内掌握开发iPhone和iPad应用程序的关键技能。这本书由一系列深入的章节组成,涵盖了从基础知识到高级...

    Mastering.Core.Data.With.Swift.2017

    - **Object Graph Management**: Learn how Core Data manages an object graph and its implications for your app's architecture. - **Persistence**: Gain knowledge about persistent stores and their ...

    Pro Core Data for iOS, Second Edition

    As people like you join the app-creation party, they usually discover that their apps must store data on iOS devices to be useful. Enter Pro Core Data for iOS, written for developers who have learned...

    iOS.8.App.Development.Essentials

    Title: iOS 8 App Development Essentials Author: Neil Smyth Length: 824 pages Edition: 1 Language: English Publisher: CreateSpace Independent Publishing Platform Publication Date: 2014-12-16 ISBN-10: ...

    The way to go

    Chapter 4—Basic constructs and elementary data types.......................................................49 4.1. Filenames—Keywords—Identifiers......................................................

    Learning.iPhone.Programming.from.xcode.to.app.store

    《Learning iPhone Programming: From Xcode to App Store》是2010年由OREILLY出版社推出的一本面向初学者的iPhone编程指南。这本书以其详尽的内容和实用的教程,为想要踏入iOS开发领域的读者提供了全面的知识体系。...

    iOS.9.App.Development.Essentials

    iOS 9 App Development Essentials is latest edition of this popular book series and has now been fully updated for the iOS 9 SDK, Xcode 7 and the Swift 2 programming language. Beginning with the ...

    一个appStroe上线项目的源码

    【描述】: 在这个源码包中,我们有一个已经成功在AppStore上发布的项目,它的功能和界面设计与微博应用相似。这个项目对于开发者来说,是一个宝贵的资源,可以深入学习如何构建、优化并发布iOS应用程序。通过对源...

    Xcode 升级到 12

    8. **Core Data优化**: Xcode 12可能会对Core Data进行优化,改善数据持久化的效率和性能,为开发者提供更好的数据管理体验。 9. **App Clips**: 新的iOS 14特性App Clips在Xcode 12中会有相应的支持,开发者可以...

    [Go语言入门(含源码)] The Way to Go (with source code)

    The Way to Go,: A Thorough Introduction to the Go Programming Language 英文书籍,已Cross the wall,从Google获得书中源代码,分享一下。喜欢请购买正版。 目录如下: Contents Preface......................

    Core Data by Tutorials iOS 12 and Swift 4.2, 5th Edition 解密版

    《Core Data by Tutorials iOS 12 and Swift 4.2, 5th Edition 解密版》是专注于iOS开发的教材,主要讲解了如何在使用Swift 4.2语言开发iOS 12应用程序时,集成和利用Core Data框架进行数据持久化操作。本书是由...

    app-store-clone:使用Swift重新创建App Store

    【标题】"app-store-clone:使用Swift重新创建App Store" 涉及的主要知识点是使用Apple的编程语言Swift来构建一个类似苹果App Store的应用程序。这个项目旨在为开发者提供一个学习平台,让他们能深入了解iOS应用开发...

Global site tag (gtag.js) - Google Analytics