UITextField.text is not always there!

If you have UITextField in your app and you want to validate a value or  see is there something in it you might think to write some code like this:

if (![addNewCellTextField.text isEqualToString:@""])

You would be right, but this will fail if the field is never touched! When a user taps the field, and it gets focus, UITextField.text = nil. That means that the condition above would be true, thats not what we want at all!

But once the UITextField is touched, the value becomes an instance of NSString with value of @””.  So make sure that you write your code to check for the nil case, like this:

if (addNewCellTextField.text != nil && ![addNewCellTextField.text isEqualToString:@""])