• 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: Why does NSCollectionView want to encode items in PopUp Menu?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does NSCollectionView want to encode items in PopUp Menu?


  • Subject: Re: Why does NSCollectionView want to encode items in PopUp Menu?
  • From: Jerry Krinock <email@hidden>
  • Date: Wed, 16 Jun 2010 18:44:31 -0700

On 2010 Jun 16, at 17:03, Graham Cox wrote:

> On 17/06/2010, at 9:20 AM, Jerry Krinock wrote:
>
>> Why might the collection view feel it needs to encode the items in this popup menu?
>
> Isn't the view template copied by archiving/dearchiving, since NSView doesn't support NSCopying?

Hmmm.  Possible, Graham.  But if this was true, it seems there would be hell to pay in the 2nd and subsequent collection view items, because of my "no-op" implementations:

- (void)encodeWithCoder:(NSCoder *)encoder {
}

- (id)initWithCoder:(NSCoder *)decoder {
    self = [super init] ;

    if (self) {
    }

    return self ;
}

Note that I do *not* encode my three instance variables, and super is NSObject, so these things are quite useless.  One of the instance variables of this class is a managed object which I *don't* want copied or encoded.  This class can not and should not be encoded as far as I'm concerned.  (I did try it to encode the managed object's pointer as an NSValue but couldn't get it to work.  Runtime kept telling me that it couldn't encode a void*, so I gave up.)  Implemented as above and voila!

> A similar problem I've run into is that when you set -representedObject on a menu item that has any possibility of being displayed in a toolbar, collection view or any other place that might be "copied", the object set must conform to NSCoding. On 10.5, toolbar items were copied in this way when displayed in the customise sheet, though in 10.6 that was changed to just render an image of the control instead (since the controls don't need to actually function there). But for views that must be functional, that wouldn't work so representedObjects must support NSCoding. It might be worth filing a bug against the docs for that method to point out this.

Will do, once we get a sensible explanation.

_______________________________________________

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: Why does NSCollectionView want to encode items in PopUp Menu?
      • From: Jerry Krinock <email@hidden>
References: 
 >Why does NSCollectionView want to encode items in PopUp Menu? (From: Jerry Krinock <email@hidden>)
 >Re: Why does NSCollectionView want to encode items in PopUp Menu? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Add button to Finder
  • Next by Date: DnD International No symbol
  • Previous by thread: Re: Why does NSCollectionView want to encode items in PopUp Menu?
  • Next by thread: Re: Why does NSCollectionView want to encode items in PopUp Menu?
  • Index(es):
    • Date
    • Thread