gpt4 book ai didi

ios - 魔法记录: nil is not a legal NSPersistentStoreCoordinator

转载 作者:可可西里 更新时间:2023-11-01 06:05:52 31 4
gpt4 key购买 nike

我正在使用 MagicalRecord,

这就是我设置 coreData 堆栈的方式

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Magical record

[MagicalRecord setupCoreDataStackWithStoreNamed:@"HITO.sqlite"];

我是这样用的

- (void)getQuizzessWithCompletion:(void(^)(NSArray *quizzess, BOOL succes, NSError *error))completion {
NSManagedObjectContext *backGroundContext = [NSManagedObjectContext MR_newPrivateQueueContext] ;
NSArray *quizzess = [Quiz MR_findAllInContext:backGroundContext];
BlockSafeRun(completion, quizzess, YES, nil);
}

这就是我得到的

2015-06-17 19:50:53.358 HITO[6677:611576] Created new private queue context: <NSManagedObjectContext: 0x61f990>
2015-06-17 19:50:57.230 HITO[6677:611576] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSPersistentStoreCoordinator for searching for entity name 'Quiz''

enter image description here

核心数据堆栈似乎没有正确设置。我试过改变设置核心数据栈的方法,但没有成功。

最佳答案

您应该创建默认上下文,然后创建新的私有(private)上下文,然后将默认上下文设置为私有(private)上下文的父级

NSManagedObjectContext *mainContext = [NSManagedObjectContext MR_defaultContext];
NSManagedObjectContext *privateQueueContext = [NSManagedObjectContext MR_newPrivateQueueContext];
[privateQueueContext setParentContext:mainContext];

NSArray *quizzess = = [Quiz MR_findAllInContext:privateQueueContext];

关于ios - 魔法记录: nil is not a legal NSPersistentStoreCoordinator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30897804/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com