Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What does it mean when po puts % before class name?



On Jul 30, 2004, at 5:24 PM, Greg Parker wrote:

On Jul 30, 2004, at 1:08 PM, Jim Correia wrote:
Thanks Greg. That got me to the point that I could debug the problem. A nameless Apple framework (nameless to protect the guilty :-) - I'll file a bug) has a private class which does a poseAsClass: [NSView class] the first time it is used - which happens much after application startup.

Thus demonstrating why using +poseAsClass: is dangerous when instances of the original class may exist. Bad framework, no biscuit.

Thanks. I'll file a bug and you can chastise the person internally which is responsible :-)

Yes. This is correct though non-intuitive behavior. The problem is that [NSView class] returns a different result after an impostor poses as NSView.

Thanks for the explanation.

There are potential ripple effects, but you may or may not run across problems because of them. The problem is that your implementation of -isKindOfClass: is lying; after posing, your old instances really aren't instances of the new NSView class. Some code might be confused because your old instances claim to be NSView but don't act like other NSViews, but such code may be rare.

A second workaround may be to use a custom subclass of NSView for your instances, and never actually instantiate NSView itself. The extra level of subclassing would protect you from any ill effects of posing.

I can investigate that approach. Part of the problem is that I'm getting an exception raised in code when you set the font panel accessory view. This isn't a custom view and this failure might cause problems in other places as well.

Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: What does it mean when po puts % before class name? (From: Greg Parker <email@hidden>)
 >Re: What does it mean when po puts % before class name? (From: Jim Correia <email@hidden>)
 >Re: What does it mean when po puts % before class name? (From: Greg Parker <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.