Re: Extending NSMutableDictionary what am I doing wrong?
Re: Extending NSMutableDictionary what am I doing wrong?
- Subject: Re: Extending NSMutableDictionary what am I doing wrong?
- From: Public Look <email@hidden>
- Date: Thu, 26 Feb 2004 18:43:58 -0500
I have not been following this thread, but adding -title, and -text
methods to NSMutableArray seems like a very odd thing to do. Array's
don't have titles or text.
I have to suspect that what is really needed in a new class that
contains a mutable array as well as a title and some text. "Has A"
relationships are almost always better than "Is A" relationships
between classes IMHO.
On Feb 26, 2004, at 2:14 PM, b.bum wrote:
On Feb 26, 2004, at 5:30 AM, Ondra Cada wrote:
Meatime, consider whether a category would be sufficient for the
extension you need: if so, just use it. Categories work with class
clusters like a charm, and using them is *WAYS* easier than
subclassing anyway.
Sort of.
In this case, the developer wants....
- (NSString*)title;
- (NSData*)text;
.... and adding those two methods as a category on NSMutableDictionary
will result in every dictionary in the entire runtime responding to
those two methods. This will change the behavior of -valueForKey:.
If there is any UI element bound to 'text' or 'title' in any piece of
UI anywhere in the app -- regardless of whether it was originally a
part of the app or a plugin or a part of Cocoa -- those keys will no
longer be unbound.
Categories are very powerful and convenient. They are also dangerous.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.