Re: Subclass of NSMutableDictionary hanging
Re: Subclass of NSMutableDictionary hanging
- Subject: Re: Subclass of NSMutableDictionary hanging
- From: Keary Suska <email@hidden>
- Date: Sat, 03 Mar 2007 11:10:01 -0700
- Thread-topic: Subclass of NSMutableDictionary hanging
on 3/2/07 11:31 PM, email@hidden purportedly said:
> 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. Here is the code for my custom init method:
In short, if you don't already know, you can't subclass collection objects
like you can any other old object, as they are not concrete classes. I
believe this applies to all Cocoa data object including NSString and
NSNumber as well.
If you delve into the docs, they will tell you how you would need to
subclass these objects, and it is a very nontrivial endeavor.
Possible alternatives depend on your needs. If your objects will tend to
have fixed members, you are probably better off with a home-grown object
with accessors. you can use the KVC -valueForKey methods for access
syntactically similar to a dictionary, for more flexible access.
If your member count is large or varies significantly you could have a
custom object that maintains a dictionary and override the KVC
-valueForUndefinedKey methods in your object for transparent access to the
dictionary.
If you need all the bells and whistles of a dictionary, but need a few
features that NSDictionary doesn't offer, you are probably better off using
a category as previously posted.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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