Not directly related to the book, but I hope someone can help.
I’m using the book (and other resources such as Tim Isted’s blog entries) to help me with my app, which creates objects in new windows instead of the tables. I’ve got it working fine for simple objects, but when I try to add an object with a relationship, it complains the entities are in two different contexts. They are, and I know why, but I don’t know how to solve it.
The new window has its own managedObjectContext while I’m creating the new entity. This is so only when I click “Save” does the object actually get added to the main MOC. (Otherwise, it saves after each field loses focus, which is not what I want.) The problem is, the objects in the dropdown box (a list of Categories to add a type to a person in an address book) have to be in the main MOC (since that’s where the Categgory entities are), not in the window MOC. Whenever I select one from the dropdown box, it complains about the different contexts. When I save, the object itself gets saved to the main context (in my method that I explicitly do this in), but I don’t know how to make the relationship do it.
Is there any way I can make the relationship to the entity based on the string of the value? Would a FetchRequest be able to do that for me?