• 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: Bill Bumgarner <email@hidden>
  • Date: Fri, 8 Jul 2005 22:03:24 -0700

On Jul 8, 2005, at 8:08 PM, email@hidden wrote:
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.

Given that you are writing a test harness, can you safely attempt to modify the returned collection and catch the exception if it is immutable?


I.e.

@try {
    [returnArray addObject; 0];
} @catch {id e} {
    /// nope, not mutable
    return;
}

// hey, we mutated... boo.
_______________________________________________
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


References: 
 >Determining if NSArray/NSDictionary is immutable (From: email@hidden)

  • Prev by Date: Re: Getting all managed objects of given entity
  • Next by Date: Re: Getting all managed objects of given entity
  • Previous by thread: Re: Determining if NSArray/NSDictionary is immutable
  • Next by thread: Re: Determining if NSArray/NSDictionary is immutable
  • Index(es):
    • Date
    • Thread