Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get NSString first word only

Tags:

objective-c

I am having this NSString, that gives me the user language .

NSString * language= @"English (America) " ;

I need to get from it ONLY the first word- which is the language . I know how to find space, but could not find a simple way to get only the first word.

ThAnks.

like image 782
Curnelious Avatar asked Nov 28 '12 09:11

Curnelious


1 Answers

NSString *firstWord = [[language componentsSeparatedByString:@" "] objectAtIndex:0];
like image 150
Fogmeister Avatar answered Sep 23 '22 15:09

Fogmeister