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: Subclass of NSMutableDictionary hanging



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

This email sent to email@hidden
References: 
 >Subclass of NSMutableDictionary hanging (From: Nick Forge <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.