views:

20

answers:

3

I have the following define'd constant set up.

#define EndDateNotSpecified "None"

But I can't seem to evaluate it, I've tried

if (btnEndDate.titleLabel.text != EndDateNotSpecified) {

and

if (btnEndDate.titleLabel.text isEqualToString:EndDateNotSpecified) {

I get compiler problems with each.

+1  A: 

Close, just missing brackets around the method call, like

if ([btnEndDate.titleLabel.text isEqualToString:EndDateNotSpecified]) {

And in the future, it generally helps if you tell us what the specific compiler error was.

Rob Lourens
+1  A: 

You missed an @ for the string, remember to add this to every string constant:

#define EndDateNotSpecified @"None"
sfa
+1  A: 

In objective C, you have to call a method in [] so the second one should be: if ([btnEndDate.titleLabel.text isEqualToString:EndDateNotSpecified]) {

Don't use this because it will not always give correct result when you only compare the NSString pointer object

if (btnEndDate.titleLabel.text != EndDateNotSpecified) {

Generally, I think you should learn the basic Objective-C, your code doesn't look like a obj-c code. No [], no @"" for String:(

vodkhang