Vipin
Vipin

Reputation: 4728

Displaying the contents in a text box in all uppercase

In my app i have a text box and i am required to perform some validations in it .And also separating the contents present in the text box based on space between them and storing them in an array for further use.Now i want that the input is provided thorugh the text box is all converted to UPPERCASE before being split using spaces.I have already searched many places but havent found anything.This is my last option now,please help.My code is:-

wordsInSentence = [youSaid.text componentsSeparatedByString:@" "];

i want to bring the text in youSaid(my text box) in UPPERCASE and then storing them into an array by splitting with space.

Thanks,

Christy

Upvotes: 3

Views: 3196

Answers (2)

EmptyStack
EmptyStack

Reputation: 51374

To get the uppercase string:

NSString *uppercaseString = [textField.text uppercaseString];

And, if you want the text field to display text in upper case(while typing), use autocapitalizationType property.

textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;

Upvotes: 4

jamapag
jamapag

Reputation: 9318

NSString* uppercase = [youStaid.text uppercaseString];
wordsInSentence=[uppercase componentsSeparatedByString:@" "];

Upvotes: 1

Related Questions