Core Data attribute changes to nil (ARC related?)

♀尐吖头ヾ 提交于 2019-12-03 14:14:24

This is very likely because the NSManagedObjectContext that these objects belong to, is going away. When you have NSManagedObject instances around but you're not holding on to the context yourself, those managed objects will start returning nil.

Under ARC, make sure you store the context in a strong variable, i.e. an instance variable that's not weak or a static global.

Non-ARC, i.e. retain-release code, make sure you're retaining the context.

As others mentioned (it was my case also), be sure that you haven't reset your managed object context because if you do, all Entities stored as properties will have data: <fault>.

If you do reset your managed object context, you will also have to re-fetch the Entity itself.

check the viewDidLoad-Method

profile = [NSEntityDescription insertNewObjectForEntityForName:@"MyProfile" inManagedObjectContext:profileContext];

hope this works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!