• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Adding new Core Data objects through a form
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding new Core Data objects through a form


  • Subject: Re: Adding new Core Data objects through a form
  • From: Martin Cote <email@hidden>
  • Date: Wed, 28 Oct 2009 09:29:04 -0400

I just replied directly to Kyle, here's my response:

On Wed, Oct 28, 2009 at 12:16 AM, Kyle Sluder <email@hidden> wrote:
> On Tue, Oct 27, 2009 at 6:58 PM, Martin Cote <email@hidden> wrote:
>> I'm trying to do something really simple with Core Data, but I can't
>> find a graceful way to do it.
>
> Perhaps we can agree on "idiomatic?"  Which is quite different from
> "idiot-o-matic," though I always seem to read it that way.  ;-)

Agreed!

>> 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.
>
> Rather than binding to a temporary managed object, as in Scenario 1
> (which raises even questions about other parts of your app—like entity
> mode array controllers—dealing with this transient object being
> created), the idiomatic approach would be to bind the fields to
> properties of a controller object for your form.  (In practice, this
> might be an NSWindowController/NSViewController subclass, an
> NSObjectController subclass, or a one-off NSObject subclass.)  Then
> you wire up your button to a method on that controller that commits
> editing and creates the managed object.

Well, that's pretty much what I'm doing right now.  What I don't like
about this approach is the manual managed object creation (and setting
up all its properties).  Now I realize that I must sound like a very
lazy person.  I was just hoping I could bind my GUI directly to a
managed object instead of using an intermediate controller object.

> Alternatively, you could forego bindings and create traditional
> outlets to your UI objects, querying them from within your button's
> action method.  But bindings make the work so much easier, especially
> with NSEditorRegistration-conforming controllers!

Oh, NSEditorRegistration sounds interesting.  I'll continue reading.

> To be honest, this is a very fundamental Cocoa pattern, yet it took me
> the better part of two years to get a handle on it.  Here's what it
> looks like in action (warning, code typed in compose window!):

<snip code sample>

> Hope that helps.  I think I'm going to need to write a blog post to
> make that clearer.  First step would be to get a blog, I guess.

That helps very much.  It's not exactly what I had in mind, but it is
certainly enlightening!

Let me know if you ever get that blog live ;)

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

References: 
 >Adding new Core Data objects through a form (From: Martin Cote <email@hidden>)
 >Re: Adding new Core Data objects through a form (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Adding new Core Data objects through a form
  • Next by Date: Updating property of core data entity does not update outline view
  • Previous by thread: Re: Adding new Core Data objects through a form
  • Next by thread: can the button responce the second click before the first is finished before?
  • Index(es):
    • Date
    • Thread