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

Re: Determining if NSArray/NSDictionary is immutable


  • Subject: Re: Determining if NSArray/NSDictionary is immutable
  • From: Scott Anguish <email@hidden>
  • Date: Sat, 9 Jul 2005 00:20:11 -0400


On Jul 8, 2005, at 11:08 PM, email@hidden wrote:

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.

could you not just test for one of the required primitives for the mutable version?


addObject:
insertObject:atIndex:
removeLastObject
removeObjectAtIndex:
replaceObjectAtIndex:withObject:

    if it responds to the selector, then you'd be mutable.



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.

_______________________________________________
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: Ken Tozier <email@hidden>
References: 
 >Determining if NSArray/NSDictionary is immutable (From: email@hidden)

  • Prev by Date: Re: Coredata Applications and accessing Managed Objects
  • Next by Date: Re: NSCombobox subclass and binding ?
  • Previous by thread: Determining if NSArray/NSDictionary is immutable
  • Next by thread: Re: Determining if NSArray/NSDictionary is immutable
  • Index(es):
    • Date
    • Thread