After a great amount of trial and error, It is my belief that I would like to use Core Data with bindings in order to keep my UI synced with my model objects. Here's the summary:

I have a custom view (CellMapView) controlled by a custom window controller (CellMapController) in an NSPersistentDocument-based application. In my nib for the Cell Map window there is an NSArrayController that is set up to manage a "Cell" entity (and bound to my documents managedObjectContext) which I would like to mediate between all of my Cell models and the CellMapView. So there is a button "New Cell". This is connected to the NSArrayController's "add:" action. When the user clicks it, a new Cell entity is entered in to the MOM and all is good in the world. But wait! There's more...

Adding a cell, in addition to creating a new Cell entity, also has to do some custom tasks on initialization. Each cell has a one-to-one relationship with another managed object (Scene), so the scene object needs to be created and inserted in to the MOM when the cell is created. Also, the starting location of the cell in the CellMapView is determined by fetching all existing cells in the context and figuring out the first spot that is not occupied by a previously created cell.

I thought I had finally figured it out -- I subclass my cells ArrayController (CellsArrayController) and override the -newObject method to create the scene and set the starting location of the cell. But when the scene entity is created and the relationship between the cell and the scene is established, for some reason the "arrangedObjects" of my cells controller adds the cell being created twice. Exact same address in memory, but their are two of them.

What gives? Is overriding "newObject" not the way to go in my situation?

Thanks,
Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to