• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting NSString to char constant (answered)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
References: 
 >RE: Converting NSString to char constant (answered) (From: KLW <email@hidden>)
 >Re: Converting NSString to char constant (answered) (From: Clark Cox <email@hidden>)
 >Re: Converting NSString to char constant (answered) (From: KLW <email@hidden>)

  • Prev by Date: Column & Page breaks in multible NSTextViews
  • Next by Date: Re: Good example code for an Inspector/Get Info window?
  • Previous by thread: Re: Converting NSString to char constant (answered)
  • Next by thread: Good example code for an Inspector/Get Info window?
  • Index(es):
    • Date
    • Thread