uitextfield - iphone / objective-c how to check to see if a textfield is empty -


I have a specific textfield in an iPhone app, and in the ViewWhole I want to make a little argument using text, text field.

If txtField.text is empty, then I would like to type the next textfield, txtField2 will be selected for typing.

I'm trying to get it:

  if (txtField.text! = @ "") [TxtField2 First Responder];  

But after a few tests, txtField.text (in spaces), will still not be registered as being equal to @ "What am I missing?

When you compare two pointers variables, you actually compare addresses in memory, Indicate these two variables. Only one such case is true, when you have two variables pointing to an object (and therefore at the same address in memory).

Using a common approach to comparing an object is isEqual: defined NSObject . In this type of class as NSNumber , NSString , additional comparison methods are named isEqualToNumber: , isEqualToString: and Similarly Here is an example for your very own situation:

  if ([txtField.text is EqualToString: @ ""]) [txtField2 First Responder];  

If you want to do something, then no NSString is actually not a free use ! Here is an example to reverse the meaning of symbol expression:

  if (! [TxtField.textEqualToString: @ ""]) [txtField2 First Responder];  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -