你能帮我理解如何解决这个问题吗?我正在尝试在我可以跨多个项目使用的静态框架中添加 Magical Record 以及我的 CoreData 数据库。
我得到的例外如下:
+entityForName:在此模型中找不到名为“APIContent”的实体。
请在下面的我的模型中运行代码:
(void) insertOrUpdate:(NSDictionary *) objectDictionary {
@try {
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
APIContent *product;
// Check if Object Exists
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"id == %@", [objectDictionary objectForKey:@"id"]];
product = [APIContent MR_findFirstWithPredicate:predicate inContext:localContext];
BOOL objectIdNotFound = product == nil ? TRUE: FALSE;
if (objectIdNotFound) {
product = [APIContent MR_createInContext:localContext];
}
// Import Values from the NSDictionary object
[product MR_importValuesForKeysWithObject:objectDictionary];
[localContext saveToPersistentStoreWithCompletion:^(BOOL success, NSError *error) {
if (success) {
DDLogCInfo(@"Object saved successfully.");
} else {
DDLogError(@"Object NOT saved successfully");
}
}];
}
@catch (NSException *exception) {
DDLogError(@"Class: %@ Function: %s at Line: %d \n Exception: %@", [self class], func, LINE, exception);
}
}
谢谢,迈克尔