Re: immutable NSMutableDictionary
Re: immutable NSMutableDictionary
- Subject: Re: immutable NSMutableDictionary
- From: Shawn Erickson <email@hidden>
- Date: Mon, 17 Feb 2003 10:48:49 -0800
On Monday, February 17, 2003, at 08:59 AM, Fridiric BLANC wrote:
Quoting Shawn Erickson <email@hidden>:
Its better to query if the target object supports "setObject" or catch
the exception then attempting to verify class.
if ([myDictionary respondsTo:@selector(setObject:forKey:)])
{
[myDictionary setObject: myObject forKey: myKey];
}
I do understand why this is better... but could you please give us
your Java
version of this great tip ;) ? Thanks in advance,
Java is a statically typed language and runtime so...
if (NSMutableDictionary.isInstance(myDictionary)) {
((NSMutableDictionary)myDictionary).setObejctForKey(myObject, myKey);
}
or you could use reflection but the above should be sufficient.
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.