Re: Where can I get some examples of if() conditionals being used with string variables in Objective-C
Re: Where can I get some examples of if() conditionals being used with string variables in Objective-C
- Subject: Re: Where can I get some examples of if() conditionals being used with string variables in Objective-C
- From: Paul Bruneau <email@hidden>
- Date: Wed, 25 Jun 2008 08:41:07 -0400
On Jun 25, 2008, at 8:24 AM, Papa-Raboon wrote:
Hi All,
Anybody know where can I get some examples of if() conditionals
being used
with string variables in Objective-C?
To be specific, I am trying to use an if conditional to check the
value of a
string being a certain value and then replacing it with a different
value if
the condition returns TRUE.
Currently I have:
NSString *theName = [NSString stringWithFormat:@"%@ %@", [firstName
stringValue], [lastName stringValue]];
I thought that this would work but it doesn't:
if ([NSString theName] == @"John Lenon") {
You are comparing the pointer to theName with the pointer to @"John
Lenon". Try the isEqualToString: method.
Also, it's "Lennon" :)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden