• 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: Extending NSMutableDictionary what am I doing wrong?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extending NSMutableDictionary what am I doing wrong?


  • Subject: Re: Extending NSMutableDictionary what am I doing wrong?
  • From: "b.bum" <email@hidden>
  • Date: Thu, 26 Feb 2004 11:14:22 -0800

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.


  • Follow-Ups:
    • Re: Extending NSMutableDictionary what am I doing wrong?
      • From: Public Look <email@hidden>
References: 
 >Re: Extending NSMutableDictionary what am I doing wrong? (From: Ondra Cada <email@hidden>)

  • Prev by Date: CocoaInCarbon printing
  • Next by Date: Re: import regex -> can't instantiate Java class any more
  • Previous by thread: Re: Extending NSMutableDictionary what am I doing wrong?
  • Next by thread: Re: Extending NSMutableDictionary what am I doing wrong?
  • Index(es):
    • Date
    • Thread