• 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: Subclass of NSMutableDictionary hanging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclass of NSMutableDictionary hanging


  • Subject: Re: Subclass of NSMutableDictionary hanging
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 4 Mar 2007 01:04:21 -0800

On Mar 2, 2007, at 10:31 PM, Nick Forge wrote:

I am developing a preferencePane that makes use of a subclass of NSMutableDictionary. My subclass (SPPowerSourceSettings) has only three methods, which is one custom init method and a pair of "get and set" methods.

Unlike other responses, I'll question why you're subclassing NSMutableDictionary for this. I would subclass NSMutableDictionary to provide a new "kind" of dictionary -- e.g., one that uses a different internal representation -- rather than because I want to use an NSMutableDictionary as backing store for an instance of an object.


In the latter case, I'd just have an NSMutabelDictionary as an instance variable, and have the appropriate accessor methods in my class call through to it. The general rule of thumb is to use subclassing for "is-a" relationships between classes and composition for "has-a" relationships.

  -- Chris


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Subclass of NSMutableDictionary hanging
      • From: Nick Forge <email@hidden>
References: 
 >Subclass of NSMutableDictionary hanging (From: Nick Forge <email@hidden>)

  • Prev by Date: Re: NSUserDefaults won't do as it's told
  • Next by Date: Re: Notifications
  • Previous by thread: Re: Subclass of NSMutableDictionary hanging
  • Next by thread: Re: Subclass of NSMutableDictionary hanging
  • Index(es):
    • Date
    • Thread