In my iPhone application, I want to use the first character in a UITextField text.
How can I do that?
Plain:
NSString *text = [textField text]; NSString *capitalized = [[[text substringToIndex:1] uppercaseString] stringByAppendingString:[text substringFromIndex:1]]; NSLog(@"%@ uppercased is %@", text, capitalized);
In the Builder interface (or IB integrated into Xcode 4), if you click on UITextField, you can set the behavior of the text and keyboard.
NSString * capitalizedString = [textField.text capitalizedString];
Here I suggest you try. Hope this will be helpful for you.
Go to xib, select the text box, then in the attribute inspector you got the header version, just select the words option
If you set the text field in the nib file, select nib, you will see various "text input traits" in the attributes of the text field - the first one deals with capitalization.
see rjstelling answer .....
Set the value "Capitalization" in the attributes of the text field to "Offers".
Instead of tanking it separately and capitalizing, try this. Simple 1-line code.
NSString *text = [textField text]; NSString *capText = [text capitalizedString]; // capitalizes only first alphabet.