Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Bindings: Specifying the Class of a Controller’s Content (From: "Oleg Krupnov" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.