Sunday, June 2, 2013

UITextField text example in Objective C (iOS).

UITextField text

The text displayed by the text field.

@property(nonatomic, copy) NSString *text

Discussion of [UITextField text]
This string is nil by default.

In iOS 6 and later, assigning a new value to this property also replaces the value of the attributedText property with the same text, albeit without any inherent style attributes. Instead the text view styles the new string using the font, textColor, and other style-related properties of the class.

UITextField text example.
userName = [NSString stringWithFormat:@"%@", yournamefield.text];

Example of [UITextField text].
mytext = [ [ NSString alloc ] initWithUTF8String:"Init'd with utf8" ] ;
tf.text = mytext;
[mytext release];

UITextField text example.
you have to use the textfield delegate

-(void)textFieldDidEndEditing:(UITextField *)textField;
in this delegate make check like this

if ( [textField.text length] > 0 )
    // the text field is empty do your work

End of UITextField text example article.