应用程序更新后的CoreData崩溃 [英] CoreData Crash after App Update

查看:121
本文介绍了应用程序更新后的CoreData崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常恼人的问题。我有一个CoreData应用程序,目前在生产和一切工作正常。我有一个应用程序的更新,但每当更新安装在原始应用程序时,应用程序崩溃就在下面的代码行。

I have a very annoying issue. I have a "CoreData" app that is currently in production and everything works fine. I have an update for the app, but whenever the update is installed over the original app the app crashes right on the line of code below.

[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]

我收到的错误是无法使用具有提取属性描述(实体模型不匹配)的获取请求。

The error I receive is "Can't use fetch request with fetched property description (entity model mismatch).".

CoreData模型已更改,但是我为我的更改创建了一个新版本的模型,因此它应该将更改合并到新模型中。这是我做过一百次的同一个过程,总是工作。除了这一次。

There have been changes to the CoreData model, but I created a new version of the model for my changes, so it should merge the changes into the new model. This is the same process I have done a hundred times, and always works. Except for this time.

我能想到的唯一的区别可能会导致这个问题是,我从CoreData模型中删除了一些旧的获取请求,但是,在更新的模型版本中完成,而不是原始模型。

The only difference I can think of that could cause this issue is that I removed some old Fetch Requests from the CoreData model, but once again this was done in the updated model version and not the original model.

你们都知道什么可能导致这种情况吗?正如我所提到的,我更新了CoreData模型版本,并将其选择为我当前的应用程序模型。另外,很奇怪的是,崩溃只发生在第一次运行应用程序更新后。发生崩溃后,我可以重新启动应用程序,一切正常。

Do you all have any idea what could cause this? As I mentioned I did update the CoreData model version and selected it as my current model for the app. Also, what is very strange is the crash only happens the first time you run the app after the update. After the crash occurs I can re-launch the app and everything works fine.

谢谢!

* EDIT **!

!** EDIT **!

如果这有助于我的调用堆栈。

If this helps here is my call stack.

Last Exception Backtrace:
0   CoreFoundation                  0x32ac029e __exceptionPreprocess + 158
1   libobjc.A.dylib                 0x3a95697a objc_exception_throw + 26
2   CoreFoundation                  0x32ac01c0 +[NSException raise:format:] + 100
3   CoreData                        0x328a2678 -[NSFetchedPropertyDescription setFetchRequest:] + 164
4   CoreData                        0x328a2788 -[NSFetchedPropertyDescription _createCachesAndOptimizeState] + 76
5   CoreData                        0x32899b0a -[NSEntityDescription(_NSInternalMethods) _createCachesAndOptimizeState] + 1238
6   CoreData                        0x328d18a6 -[NSManagedObjectModel(_NSInternalMethods) _createCachesAndOptimizeState] + 702
7   CoreData                        0x3284e534 -[NSManagedObjectModel(_NSInternalMethods) _setIsEditable:optimizationStyle:] + 272
8   CoreData                        0x3284e2f2 -[NSPersistentStoreCoordinator initWithManagedObjectModel:] + 302
9   CoreData                        0x32939c4c -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 692
10  CoreData                        0x328da838 -[NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 512
11  CoreData                        0x3292bc54 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 276
12  CoreData                        0x3292afa8 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 84
13  CoreData                        0x3292c4b2 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 1930
14  CoreData                        0x3284f384 -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 3340
15  MSM iPad                        0x001cb4c2 -[VS_CoreDataManager persistentStoreCoordinator] + 466
16  MSM iPad                        0x001cbb12 -[VS_CoreDataManager initializeCoreDataWithProjectName:] + 94
17  MSM iPad                        0x000b6678 -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:117)
18  UIKit                           0x34928ad4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 248
19  UIKit                           0x3492865e -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1186
20  UIKit                           0x34920846 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 694
21  UIKit                           0x348c8c34 -[UIApplication handleEvent:withNewEvent:] + 1000
22  UIKit                           0x348c86c8 -[UIApplication sendEvent:] + 68
23  UIKit                           0x348c8116 _UIApplicationHandleEvent + 6150
24  GraphicsServices                0x365bc59e _PurpleEventCallback + 586
25  GraphicsServices                0x365bc1ce PurpleEventCallback + 30
26  CoreFoundation                  0x32a9516e __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
27  CoreFoundation                  0x32a95112 __CFRunLoopDoSource1 + 134
28  CoreFoundation                  0x32a93f94 __CFRunLoopRun + 1380
29  CoreFoundation                  0x32a06eb8 CFRunLoopRunSpecific + 352
30  CoreFoundation                  0x32a06d44 CFRunLoopRunInMode + 100
31  UIKit                           0x3491f480 -[UIApplication _run] + 664
32  UIKit                           0x3491c2fc UIApplicationMain + 1116
33  MSM iPad                        0x000b6432 main (main.m:17)
34  libdyld.dylib                   0x3ad8db1c start + 0


推荐答案

我发现我必须在应用程序更新后删除缓存:

I've found I must delete the cache after app updates:

/ p>

Either don't cache fetched items

 NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];

或在更新时删除缓存

[NSFetchedResultsController deleteCacheWithName:@"Master"];

这篇关于应用程序更新后的CoreData崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆