• 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
Know about Mutability
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Know about Mutability


  • Subject: Know about Mutability
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 14 Jan 2005 09:35:37 +0700

I have a
NSDictionary *myDict ;
which is either a NSDictionary or a NSMutableDictionary.

When I want to modify myDict I have to make a mutableCopy of it (otherwise I get an exception: *** -[NSCFDictionary setObject:forKey:]: mutating method sent to immutable object).

But how do I know whether myDict is mutable or not?
Actually myDict seems to be a NSCFDictionary (NSObject -> NSDictionary -> NSCFDictionary -> NSMutableDictionary -> %NSCFDictionary -> NSCFDictionary)


And so neither [ myDict respondsToSelector: @selector(setObject:forKey:) ] nor [ myDict isKindOfClass: [ NSMutableDictionary class ] ] are of any help.

What I need is something like: [ myDict isMutable ]. But I can't find such a method.
So currently I always make a mutable copy, which seems rather inefficient if myDict already is mutable.


What can be done?

Kind regards

Gerriet.

_______________________________________________
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: Know about Mutability
      • From: James Bucanek <email@hidden>
    • Re: Know about Mutability
      • From: Bob Ippolito <email@hidden>
  • Prev by Date: Re: Adding an undo method in textView:shouldChangeTextInRange:...
  • Next by Date: Re: Know about Mutability
  • Previous by thread: Re: Bindings Book !!!!!Stepping back from this,
  • Next by thread: Re: Know about Mutability
  • Index(es):
    • Date
    • Thread