• 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: Dereferencing a pointer in ObjC?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dereferencing a pointer in ObjC?


  • Subject: Re: Dereferencing a pointer in ObjC?
  • From: Ondra Cada <email@hidden>
  • Date: Mon, 29 Jul 2002 14:41:47 +0200

On Monday, July 29, 2002, at 09:27 , Terry Simons wrote:

I have the following code:

if(@"Red" == [[myRadioMatrix selectedCell] title]) {
//do something
}

Now... I can't do this because @"Red" is an NSString, but [[myRadioMatrix selectedCell] title] is an NSString *.

Actually, you _can_ do that, since @"Red" is NSString* too. Nevertheless, you should not -- it would not work as you wanted it to, since strings (of course) are not runtime coalesced.

What you meant to was

if ([[myRadioMatrix selectedCell] title] isEqualToString:@"Red"]) ...

Of course, for localizations' sake, this code is bad too. What you really wanted (I guess) was something like

if ([[myRadioMatrix selectedCell] tag]==MY_RED_TAG_NUMBER) ...
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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: 
 >Dereferencing a pointer in ObjC? (From: Terry Simons <email@hidden>)

  • Prev by Date: Re: code example on NSThread
  • Next by Date: Re: Creating a class cluster
  • Previous by thread: NSOpenPanel question
  • Next by thread: Re: espace disque nécessaire pour 10.2
  • Index(es):
    • Date
    • Thread