0
我是CoreData和MR的新手。嘗試保存一些實體並在閱讀後進行閱讀。MagicalRecord使用
節省:
Events *newEvent = [Events MR_createEntity];
newEvent.title = @"qwe";
newEvent.date = [NSDate date];
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreWithCompletion:^(BOOL contextDidSave, NSError * _Nullable error) {}];
閱讀:
NSMutableArray *events = [NSMutableArray arrayWithArray:[Events MR_findAll]];
NSLog(@"%@",events);
的結果我收到 「數據:<故障>」
如果我添加私人方面,如:
NSManagedObjectContext *context = [NSManagedObjectContext MR_newPrivateQueueContext];
NSMutableArray *events = [NSMutableArray arrayWithArray:[Events MR_findAllInContext:context]];
我的應用程序崩潰,錯誤原因:「+ entityForName:無不是尋找實體名稱的法律NSPersistentStoreCoordinator'活動」
能有人告訴我代碼爲我的任務工作
感謝您的解釋,但此代碼仍輸出數據錯誤, 然而,我可以在此週期中打印事件屬性 – sedq
@sedq yea,我編輯了代碼:) –