Know about Mutability
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