Question

I have a NSCollectionView, whose view contains an Image Well. (NSImageView) I have an array of NSImage. I am able to bind the array to the NSCollectionview using Value > Collection View Item > representedObject

So that i see the number of items in the Collection View.

All i want is how do i bing the NSImage (present in Array - in an Array Controller) to the NSImageView (present in view of NSCollectionView)

Was it helpful?

Solution

Here is what you should do:

  1. Place an Array Controller in IB and set the Content Array binding, for example, to the File's Owner, and set the Model Key Path to your array of icons.
  2. Bind your Collection View's Content to your Array Controller, set the Controller Key to arrangedObjects.
  3. On your view (NSImageView, ImageWell or button or whatever) bind the Image to the Collection View and set the keypath to representedObject.myimage (myimage must be a property of the objects contained in your array)

There are a few other bindings and outlets linked in IB (itemPrototype, View), but I believe those are set automatically when dragging these items into your xib file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top