• 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: Subclassing best practice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing best practice


  • Subject: Re: Subclassing best practice
  • From: "A.M." <email@hidden>
  • Date: Wed, 14 Nov 2007 13:35:04 -0500


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:
This email sent to email@hidden


References: 
 >Subclassing best practice (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Subclassing best practice
  • Next by Date: Re: Subclassing best practice
  • Previous by thread: Re: Subclassing best practice
  • Next by thread: Re: Subclassing best practice
  • Index(es):
    • Date
    • Thread