Re: Converting NSString to char constant (answered)
Re: Converting NSString to char constant (answered)
- Subject: Re: Converting NSString to char constant (answered)
- From: Nick Zitzmann <email@hidden>
- Date: Fri, 2 Jan 2004 22:48:32 -0800
On Jan 2, 2004, at 10:28 PM, KLW wrote:
Anyone know if I can use a unichar in a switch() case construct? I
know, I know, I suppose I could just try it, but I happen to not have
Xcode at this machine.
The answer is yes. It is possible to do this:
switch ([someString characterAtIndex:0])
{
case 'a':
// do something based on the fact that the first character was lower
case a
break;
case 'G':
// do something based on the fact that the first character was upper
case g
break;
case ' ':
// do something based on the fact that the first character was a space
break;
case 248:
// do something based on the fact that the first character was a
lower case o with a stroke through it (Unicode 1.1)
break;
case NSLeftArrowFunctionKey:
// if you're overriding -keyDown: then you might want to know that
this is legal...
break;
}
And so on...
Nick Zitzmann
<
http://seiryu.home.comcast.net/>
S/MIME signature available upon request
"That's a funny thing to promise. Well, you can't never let anything
happen to him [Nemo]; then, nothing would ever happen to him." - Dory,
from the movie "Finding Nemo"
_______________________________________________
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.