• 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: Bindings: Specifying the Class of a Controller’s Content
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings: Specifying the Class of a Controller’s Content


  • Subject: Re: Bindings: Specifying the Class of a Controller’s Content
  • From: Ron Lue-Sang <email@hidden>
  • Date: Fri, 29 Aug 2008 12:37:08 -0700


On Aug 29, 2008, at 10:38 AM, Oleg Krupnov wrote:

Here's a fragment of documentation from the "Cocoa Bindings
Programming Topics" guide:

"In order for a controller to create new content objects automatically
or in response to the target-action methods, it must know the
appropriate class to use."

My question is: what is a real example of a case when the controller
needs to create new content objects?

Like Dave said, add: - the IBAction method.
Also if you call newObject for any reason, which is usually to fiddle with the result before calling addObject:





As far as I see, it can only happen when a view sends addObject to the
controller, but in that case the object is already created and the
controller simply adds it to the collection. Have I missed something?

Also, if the controller does need to know the class/entity of the
content object, what about polymorphic objects? I.e. I have one
abstract entity "Shape" which is not directly instantiatable, and a
few concrete subclasses. What entity should I specify?

If you have multiple concrete classes, then entity mode won't work for you by default. Subclass the arraycontroller and override newObject to return the kind you want, or don't depend on the controller object creation convenience - create the managedObjects yourself directly and either add them to the controller, if you're not using auto-prepare contents, or - if your controller *is* set to auto-prepare contents - wait for the controller to get the notification from the MOC that a new managedObject of your abstract entity was created and inserted into the context.



_______________________________________________

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


--------------------------
RONZILLA



_______________________________________________

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: 
 >Bindings: Specifying the Class of a Controller’s Content (From: "Oleg Krupnov" <email@hidden>)

  • Prev by Date: Re: understanding conversions between CF and NS datatypes
  • Next by Date: Re: understanding conversions between CF and NS datatypes
  • Previous by thread: Re: Bindings: Specifying the Class of a Controller’s Content
  • Next by thread: Checking for memory leaks with Instruments
  • Index(es):
    • Date
    • Thread