Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ledzepster

macrumors newbie
Original poster
Hi,

I've spent hours looking for an answer to what I know is a newbee question but to no avail. I know the solution has to be straightforward but....

I want to use the title from a button to perform a task. What I have is the following:

-(IBAction)doSomethingWithButton: (id)sender {

NSString *whatToDo = [(UIButton *)sender currentTitle];
if (whatToDo == @"+")
{//do some action
}
[whatToDo release];
}

The problem is that the logical operator doesn't work. It seems that whatToDo is type NSString and is incompatible with @"+".

Any help appreciated!

thanks
 
You cannot compare two NSStrings with ==. In fact, in general, you cannot do that with two objects: you are comparing the addresses of the pointers. Not the content of the two objects.

Is isEqualToString:
 
thanks!

thanks to both of you.obviously a fundamental flaw in my thinking - I'm from a cobol / .net background. Cheers
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.