• 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: Mutable class problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mutable class problems


  • Subject: Re: Mutable class problems
  • From: Andy Lee <email@hidden>
  • Date: Tue, 25 Jun 2002 05:29:28 -0400

At 10:50 AM +0200 6/25/02, Marco Scheurer wrote:
On Tuesday, June 25, 2002, at 06:36 am, Mike Shields wrote:
I seem to remember a conversation where checking for immutablity was bound to fail in some obscure way.

One could always define the method -(BOOL) isMutable in categories of NSDictionary, NSMutableDictionary, NSArray ...

I assume you mean NSDictionary could simply return NO, NSMutableDictionary could always return YES, etc. This would be fine (and a commonly used pattern) if NSDictionary were a normal class hierarchy. But because it's a class cluster, every dictionary, mutable or not, is an instance of NSCFDictionary (AFAICT), which is a subclass of NSMutableDictionary. This is the same reason -isKindOfClass: doesn't work.

You could have just one implementation of -isMutable which uses the brute-force logic I posted earlier, but that's extremely expensive for a call that most people would assume is very fast and cheap.

If testing for mutability is important enough, the right thing would be for *Apple* to add an -isMutable method to the NSDictionary specification (perhaps with my brute-force logic as its default implementation), and implement -isMutable in NSCFDictionary, using whatever logic it uses now to determine whether it's mutable.

And of course likewise for NSArray, NSString, etc.

--Andy
_______________________________________________
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: Mutable class problems
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Mutable class problems (From: Marco Scheurer <email@hidden>)

  • Prev by Date: Code design question
  • Next by Date: Re: Mutable class problems
  • Previous by thread: Re: Mutable class problems
  • Next by thread: Re: Mutable class problems
  • Index(es):
    • Date
    • Thread