Re: Dereferencing a pointer in ObjC?
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.