• 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: Troubles with CollectionView and IKImageBrowserView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Troubles with CollectionView and IKImageBrowserView


  • Subject: Re: Troubles with CollectionView and IKImageBrowserView
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 12 Jun 2008 07:32:09 -0700



Begin forwarded message:

From: Daniel Vollmer <email@hidden>
Date: 12 June, 2008 12:18:41 AM PDT
To: Jens Alfke <email@hidden>
Subject: Re: Troubles with CollectionView and IKImageBrowserView


On Jun 12, 2008, at 00:25, Jens Alfke wrote:


On 11 Jun '08, at 1:14 PM, Manuel wrote:

But the IKImageBrowserView doesn't call these methods. I setup a testmethod in the MYNSCollectionViewItem like the following code, to verify that the imagebrowser outlet is set and to set again the datasource:

Hm, I don't have any exact ideas, but I wonder if something's going wrong because CollectionViewItems get copied. (The one you wire up in the nib is a prototype, and the view makes a copy of it for every item it needs.) Perhaps the item is getting set as the image- browser's data source before the copy, so the instance being displayed isn't actually the one that's the data source?

Jens is right in that copying the collection view is often a problem, as NSView does not support the NSCopying protocol. There's some more information on the way that NSCollectionView copies the view here: http://www.cocoadev.com/index.pl?NSCollectionView (near the bottom).


I got it working like this:
- put your custom view initialisation in initWithCoder: (as that is the one used to copy the original instance / unarchive your nib)
- in your view, have an IBOutlet that's connected to the NSCollectionViewItem instance (called cvItem in my case)
- in awakeFromNib bind the properties you're interested in (as these get restored / set correctly in the cloning process), e.g.
- (void)awakeFromNib
{
[self bind:@"plotRoot" toObject:cvItem withKeyPath:@"representedObject" options:nil];
[self bind:@"isSelected" toObject:cvItem withKeyPath:@"selected" options:nil];
}


This setup works fine for me (ignoring the other known bugs and documentation deficiencies of NSCollectionView — it's slightly disheartening when you file a bug on it, get a dup back and realise it's been known long enough for 1094954 other bugs to be filled..).

HTH,
	Daniel.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

  • Follow-Ups:
    • Re: Troubles with CollectionView and IKImageBrowserView
      • From: Manuel <email@hidden>
  • Prev by Date: Re: argument checks
  • Next by Date: Re: FSEvent- FSEventStreamEventFlags
  • Previous by thread: Re: Troubles with CollectionView and IKImageBrowserView
  • Next by thread: Re: Troubles with CollectionView and IKImageBrowserView
  • Index(es):
    • Date
    • Thread