Adding new Core Data objects through a form
Adding new Core Data objects through a form
- Subject: Adding new Core Data objects through a form
- From: Martin Cote <email@hidden>
- Date: Tue, 27 Oct 2009 21:58:10 -0400
Hello,
I'm trying to do something really simple with Core Data, but I can't
find a graceful way to do it.
I would like to show a form to my user that they can fill, and when
they press 'OK', a new managed object is created. This can be done
very simply, but I would like to use IB bindings as much as possible.
Here's the two alternatives that I've considered, none of which is
satisfying:
- Create the managed object first, then display the form with the
fields binded to the newly created object. This doesn't feel right
since I would need to destroy the object if the user cancels.
Moreover, a partially constructed object would occur if the
application stops for some reason.
- Create a temporary object that is binded to the GUI. And "commit"
it once the user presses 'OK'. I'm not sure if this is even feasible.
I have an array controller that monitors all my objects, so the
temporary object would also be visible. I could add a boolean
attribute to my object (say "isConstructed") and use this flag to
filter the array controller, but this smells really bad.
I'm actually at lost here, and I'm starting to think that manually
settings the object's attributes from the GUI fields seems like a
better approach instead of using bindings.
Any suggestion?
Best regards,
Martin Cote
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden