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

Re: Know about Mutability


  • Subject: Re: Know about Mutability
  • From: Bob Ippolito <email@hidden>
  • Date: Thu, 13 Jan 2005 22:15:33 -0500


On Jan 13, 2005, at 21:35, Gerriet M. Denkmann wrote:

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?

I don't think anything can be done. Mutability of a CFDictionaryRef is a private implementation detail.


Use a separate method that takes a mutable dictionary as a fast-path and have the current method do mutableCopy.

-bob

_______________________________________________
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: 
 >Know about Mutability (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Know about Mutability
  • Next by Date: editing NSCell
  • Previous by thread: Know about Mutability
  • Next by thread: Re: Know about Mutability
  • Index(es):
    • Date
    • Thread