user1096463
user1096463

Reputation:

I can not get my IF command to work that wil clear the UILabel if there is nothing in a UITextField

I have got an iPad app with this as part of my code:

if (NAME1.text == @"") {
    SS1.text = @"";
    SPA1.text = @"";
}

But it does not clear the UILabel if there is nothing in a UITextField!

Does anyone know how I can get it to do what I want?

Upvotes: 0

Views: 49

Answers (2)

user523234
user523234

Reputation: 14834

Should it be:

If ([NAME1.text isEqualToString:@""])

Upvotes: 0

Jacob Relkin
Jacob Relkin

Reputation: 163228

Check the length of the string, don't do direct pointer comparison:

if ([NAME1.text length] == 0) {
    SS1.text = @"";
    SPA1.text = @"";
}

Upvotes: 2

Related Questions