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 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]