I've just used an NSCollectionView for the first time, following the 
instructions in "Quick Start for Collection Views".  The array controller's 
content is an array of Foo managed objects, which have a relationship to Bar 
managed objects.  When I got down to the subviews, I wanted a popup menu.  So I 
put in an NSPopUpButton and bound it thus:

PopUp Button Bindings
   Content:
      Bind to: File's Owner (Document's window controller)
      Model Key Path: document.availableBarChoices
   Content Values:
      Bind to: File's Owner (Document's window controller)
      Model Key Path: document.availableBarChoices.displayName
   Selected Object:
      Bind to: Collection View Item
      Model Key Path: representedObject.barChoice

BarChoice is a thin wrapper class around Bar, which adds capabilities of 
creating a new Bar from an external source.

Everything works fine, except that when the popup menu is displayed, each 
barChoice in the menu gets an -encodeWithCoder: message.  This occurs whether 
the array controller is in Entity or Class mode, and regardless of whether or 
not barChoice is listed as one of its keys.

At first, I did not have -encodeWithCoder: implemented, because there is no 
known need for it.  So I implemented -[BarChoice encodeWithCoder:] -- as a 
no-op -- and that satisfied it!

I've also implemented this with NSPopUpButtonCells in the column of a table 
view and that implementation does not have this problem.

Why might the collection view feel it needs to encode the items in this popup 
menu?

Jerry

_______________________________________________

Cocoa-dev mailing list ([email protected])

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