On 24 Dec 2009, at 05:53, Nicolas Berloquin wrote:

> Hi !
> 
> I must have killed the gods of array bindings in a previous life,
> but I'm pulling my hair (or whatever's left), and, even though I
> thought I got I, well, I really don't.
> 
> I'm trying to do something quite simple.
> I'd like to display a series of images with a label inside an
> NSCollectionView.
> Whatever I do, the collectionview remains empty (even though I can see the
> nice
> checkered background (since I set up default layout rows/cols) which
> reflects the size
> of my customized item view).

Why not use IKImageBrowserView? It's a perfect match for grids of images with 
titles. And faster too.
> 
> In a nib file that has a couple windows, the File's Owner is an
> NSWindowController
> of mine. Right now, it concentrates most of the controlling.
> The NSMutableArray which contains the images and strings is a property of
> the windowController.
> I created an NSArrayController, bound to the File's Owner, with the model
> key path to the name
> of my array (checked spelling etc).
> I created an NSCollectionView and set it up like this :
> - content is bound to the arrayController, and controller key is
> "arrangedObjects".
> - the item prototype is the NSCollectionViewItem that got created
> automatically.
> - for the NSCollectionViewItem, its view is the auto-created view that I
> customized to add an NSImageView and a label.
> Now, I tried with and without setting the fields in the "Attributes"
> inspector. Since the View is inside the same nib as
> the NSCollectionViewItem, I think I can leave this blank, since the outlet
> connects them already.
> 
> - for the view itself (that should be drawn inside the collectionview), the
> NSTextField (not the cell) is bound
> 
> to the Collection View Item, and the model key path is set to
> "representedObject._imageUID". (_ImageUID is a
> 
> property of the content of my NSMutableArray. To make it short, I add simple
> class instances that have two
> 
> fields, NSImageView *_image, NSString *_imageUID)
> 
> - the NSImageView is bound the same way, but to representedObject._image.
> 
> 
>> From what I read all over the net, this should be one way to do it...
> 
> So, now on to the model side. Maybe my array isn't observed as being
> updated.
> 
> I tried a few things...
> 
> with and without declaring the NSMutableArray as a property, and assigning
> it
> 
> through a setter in windowControllerDidLoadNib.
> 
> I use insertObject: atIndex: to add elements to the array. And I made sure
> that I add them
> 
> from the main thread (performOnMainThread or similar calls when necessary).
> 
> I traced the content of the NSCollectionView from the debugger, and it seems
> that it
> 
> doesn't see any of that. But maybe I shouldn't worry about what I see ?
> 
> The collectionView shows :
> 
> _content has 0 objects
> 
> _displayedItems has 0 objects
> 
> 
> I tried setting the NSCollectionView's content by hand, (with setContent:
> myArray) but
> 
> then I get lots of weird warnings :
> 
> *Could not connect the action orderFrontStandardAboutPanel: to target of
> class NSCollectionViewItem*
> 
> *Could not connect the action hide: to target of class NSCollectionViewItem*
> 
> Could not connect the action terminate: to target of class
> NSCollectionViewItem
> 
> *Could not connect the action hideOtherApplications: to target of class
> NSCollectionViewItem*
> 
> *Could not connect the action unhideAllApplications: to target of class
> NSCollectionViewItem*
> *
> *
> And I also tried to send setNeedsDisplay: YES to the collectionView, just in
> case...
> 
> So, if anyone has any suggestion, I'd be really glad to hear them. I really
> don't understand what
> goes wrong. Somehow, this technology, "It simply doesn't work"... :)
> 
> 
> thanks !
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to