Determining if NSArray/NSDictionary is immutable
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