Re: Switch/case with NSString?
Re: Switch/case with NSString?
- Subject: Re: Switch/case with NSString?
- From: John Stiles <email@hidden>
- Date: Wed, 03 Jan 2007 07:48:55 -0800
Yup, I was going to suggest something similar. Use an NSDictionary to do
the lookup for you.
Tommy Nordgren wrote:
On 3 jan 2007, at 11.32, d2kagw wrote:
Hi there,
Anyone know if its possible to do a switch statement with a NSString?
or if there's something similar that you could use as a replacement?
Cheers
Use a (GLOBAL)NSDictionary that maps from NSString to NSNumber.
NSNumber * switch_code = [myGlobalDictionary objectForKey: myString];
switch ([switch_code intValue]) {
----
Kine dies, Kinfolk dies, and thus at last yourself
This I know that never dies, how a dead mans deeds are deemed. --
Elder edda
Tommy Nordgren
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden