• 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
Determining if NSArray/NSDictionary is immutable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Determining if NSArray/NSDictionary is immutable


  • Subject: Determining if NSArray/NSDictionary is immutable
  • From: email@hidden
  • Date: Sat, 9 Jul 2005 13:08:44 +1000

Sorry to rehash an old topic, but I can't find an ideal solution proposed anywhere in the list archives. From the thread "Determining if NS/CFDictionary is mutable?" (which according to cocoabuilder.com should be posted about 6 months from now :) ) I found:

extern Boolean _CFDictionaryIsMutable(CFDictionaryRef ref);

That's neat enough for my exact purposes, but of course isn't good going forward. Another solution I've found is to call one of the array/dictionary's mutating methods within an exception block, and set an 'isMutable' flag to YES if an exception is thrown. But this requires turning on ObjC exceptions, which limits it's usefulness outside my own controlled uses.

So, has anyone come up with a better way to make the distinction?

And to cut a riposte off at the pass, I'm not interested in arguing about the language semantics and theorising subtleties - in my particular case I'm writing testers for code which I think really should be returning mutable or immutable instances strictly, so simply saying "it says it returns NSDictionary, so just don't mutate it" isn't a good enough answer.

Wade Tregaskis (AIM/iChat, Yahoo & Skype: wadetregaskis, ICQ: 40056898, MSN: email@hidden, AV iChat & email: email@hidden, Jabber: email@hidden)
-- Sed quis custodiet ipsos custodes?


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Determining if NSArray/NSDictionary is immutable
      • From: Douglas Davidson <email@hidden>
    • Re: Determining if NSArray/NSDictionary is immutable
      • From: Bill Bumgarner <email@hidden>
    • Re: Determining if NSArray/NSDictionary is immutable
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Project Builder Build Error
  • Next by Date: Coredata Applications and accessing Managed Objects
  • Previous by thread: Project Builder Build Error
  • Next by thread: Re: Determining if NSArray/NSDictionary is immutable
  • Index(es):
    • Date
    • Thread