views:

146

answers:

1

What is the value of a UITextField when it is empty? I can't seem to get this right.

I've tried (where `phraseBox' it the name of the said UITextField

if(phraseBox.text != @""){

and

if(phraseBox.text != nil){

What am I missing?

+1  A: 
// Check to see if it's blank
if([phraseBox.text isEqualToString:@""]) {
  // There's no text in the box.
}

// Check to see if it's NOT blank
if(![phraseBox.text isEqualtoString:@""]) {
  // There's text in the box.
}
Raphael Caixeta
Gotta wait 15 minutes to accept according to SO rules. I have 13 more min to test this, hehe ...
Moshe
Thanks for the edit. I figured out that part, with the `!`.
Moshe