NSManagedContext question

Hello,

I have a question about NSManagedObjects: suppose I have an MainEntity which has a to-many relationship with SubEntities. I want one SubEntity to be created when the MainEntity is created.

I have tried many ways but failed. I know this question is hard to answer if you don’t have the complete model, but in fact I just want to “simulate” an “add” command to the subentities array controller. If I create the SubEntity, I run into errors. If I click the “add” button, everything works fine.

Well, I’m lost. Please don’t blame me for using Core Data, this thing is really good, but. not obvious!

Thanks,

OK, that’s the code:

That’s for a non document-based application: the managedObjectContext is stored into a property. For a document-based CD app, you have to store the context somewhere but the procedure is identical. Note that if you want to change the attributes later, you must invoke KVO routines willChangeValueForKey and didChangeValueForKey before and after your change.

Well, as I read somewhere, Core Data is not for beginners. but what a joy when it works!