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: Subclassing best practice




On Nov 14, 2007, at 12:39 PM, John Stiles wrote:

I have some code which subclasses NSWindow to tack on some data of my own:
<snip>
I've run up against this problem with views as well, and I've managed to get some mileage out of categories, but there are a lot of situations where you just need to add members.

So what is the best design pattern for something like this? Anything nicer than a good old fashioned #define?

There is another trick with categories which access a static (global) dictionary with keys which are the objects to be extended and values with the additional storage. Nu does this, I believe to make Obj-C objects more dynamic.


It's easy to implement and make a transparent API, but the downside is slower (less thread-friendly) access and a clunky, sinking feeling.

Cheers,
M
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Subclassing best practice (From: John Stiles <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.