Search code examples
objective-ccore-datansmanagedobjectcontext

NSManagedObject without values


Im passing a NSManagedObject to a UIView. So Im showing a UITableView of meetings brought from CoreData, if you tap on one of the meetings you will be able to see, on another view, more info of that meeting, info that is contained in a NSManagedObject. I want to pass that NSManagedObject to the view that will show its info. So I created a init method of that view like this:

-(id)initWithMeeting:(NSManagedObject *)aMeeting{

    _theMeeting = aMeeting;

    return self;
}

Then I use the info in the _theMeeting object to show it in the view that I just created in the ViewDidLoad. The problem is that whenever I try to access any of the values of the NSManagedObject it crashes, it has values in the init but not in the ViewDidLoad. I believe it has something to do with the Managed Oriented Context, but the Managed Oriented Context never disspears, is an attribute of the AppDelegate. So I dont know how to pass that Object and keep it.

I also declared theMeeting:

 @property(nonatomic, copy)NSManagedObject *theMeeting;

Hope you can help me.


Solution

  • Are you using the accessor to assign theMeeting? I think you're just bypassing it so aMeeting is not retained or copied, and therefore the crash.