• 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: New Cocoa Programmer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Cocoa Programmer


  • Subject: Re: New Cocoa Programmer
  • From: Rainer Brockerhoff <email@hidden>
  • Date: Mon, 12 Nov 2001 22:11:29 -0200

At 18:55 -0500 on 12/11/2001, Louis Demers wrote:

>At 9:31 PM -0200 11/12/01, Rainer Brockerhoff wrote:
>> >From: Ondra Cada <email@hidden>
>>>Date: Mon, 12 Nov 2001 18:23:11 +0100
>>>If it is *not* the case, might you perhaps know why the following code is
>>>uncompilable?
>>>
>>>... switch (x) { case @selector(xyz): ... }
>>>
>>>That should be (from the compiler's prespective) a pretty equivalent
>>>situation as using class names there, or do I understand it improperly?
>>
>>I would hazard a guess here; for the same reason that
>> char* string;
>> switch (string) {
>> case "abc":
>> ...
>> case "xyz":
>> ...
>> }
>>won't work. Aren't selectors and such ultimately implemented as (possibly mangled) strings?
>
>...
>You may be confused with other C snippets like
>
> int bozo;
> switch (bozo) {
> case 'abc':
> ...
> case 'xyz':
> ...
> }

I'm not confused AFAIK... I was explicitly saying is does NOT work. Perhaps I should have expanded my text?


>You'll have to explicitly call string comparaison functions and parse the possibilities yourself, something like
>
> if( 0 == strcmp (string, "abc") {
> // do some brilliant coding here
> } else if( 0 == strcmp (string, "...") {
> // do some brilliant coding here
> } else if( 0 == strcmp (string, "xyz") {
> // do some brilliant coding here
> } else if( 0 == strcmp (string, "xyz") {
> }

That _was_ my point... you have to do the same if { } else if { } cascade if you compare selectors or classnames, since they're string-like entities.


--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"Originality is the art of concealing your sources."
http://www.brockerhoff.net/ (updated Oct. 2001)


References: 
 >Re: New Cocoa Programmer (From: Rainer Brockerhoff <email@hidden>)
 >Re: New Cocoa Programmer (From: Louis Demers <email@hidden>)

  • Prev by Date: Re: New Cocoa Programmer
  • Next by Date: Re: bad documentation
  • Previous by thread: Re: New Cocoa Programmer
  • Next by thread: Re: New Cocoa Programmer
  • Index(es):
    • Date
    • Thread