Re: Switch/case with NSString?
Re: Switch/case with NSString?
- Subject: Re: Switch/case with NSString?
- From: d2kagw <email@hidden>
- Date: Thu, 4 Jan 2007 07:52:08 +1100
Hi All!
I have a selector run after the user enters a string, depending on
the string entered, a series of different processes need to occur, if
I was writing this in a ECMA based language you would expect to see
it like ( this is an example ):
switch ( tAction )
{
case "do homework":
doHomework();
break;
case "bludge":
case "chill":
case "relax":
doRelax();
break;
default:
error("no action set for request");
}
On 04/01/2007, at 3:19 AM, Michael Watson wrote:
I'm interested to know what kind of problem d2kagw is attempting to
solve. Can you give us an example of what you're tackling?
--
m-s
On 03 Jan, 2007, at 10:48, John Stiles wrote:
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:
40blizzard.com
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:
40bungie.org
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
_______________________________________________
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