本文介绍了CoreData问题: - [NSManagedObject setValue:]:无法识别的选择器发送到实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我刚刚开始CoreData昨天,我会疯了:(我创建了一个项目,使用CoreData(勾选框 - 使用CoreData)。创建实体,然后为所有实体创建NSManagedObject类假设他们为实体创建了setter和getter方法)。 现在,我在我的AppDeletegate中导入了所有这些类,并在我的applicationDidFinishLaunching方法: (订阅是应用程式中的其中一个实体) NSManagedObjectContext * context = [self managedObjectContext]; 订阅* sbs =(Subscriptions *)[NSEntityDescription insertNewObjectForEntityForName:@SubscriptionsinManagedObjectContext:context]; [sbs setTitle:@OK]; [sbs setType:@Tag]; [sbs setCode:@cars]; NSError * error = nil; if save:& error]){ NSLog(@无法创建订阅); } 当我运行这个,我得到这个错误我不知道为什么会发生这种情况。请帮忙!!! p> I have no idea why this is happening. Please Help!!!Thanks in advance to everyone!Adding the header of SubscriptionsSubscriptions.hI didn't change anything. It's just as Xcode created it. 解决方案 Just to remind that, don't use capitalized variable name, it might affects the getters and setters not working properly.If you generated your NSManagedObject subclasses from the data model, everything should goes fine, although it is @dynamic, setters are be implemented by coredata, and because they are already implemented, you should not change it to synthesize.At least for me, coredata returns empty object after I change @dynamic to @synthesize.And don't forget to set the class name in the data model: 这篇关于CoreData问题: - [NSManagedObject setValue:]:无法识别的选择器发送到实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 12:41