Reputation: 9157
Basically I am getting a users city throughout Facebook Connect. The result is always in this format:
Sydney, Australia
But since there will be many users, the city and country can vary. Here is the format: First the city with a comma, then a space and the country.
I only want to however retrieve the country name. Is it possible for me to locate the comma in string, then remove everything behind it. Then I can replaceOccurancesOfString:" "
to remove the space.
I have seen other questions on this but they are in different languages. I am asking for Objective-C
Thanks!
Upvotes: 2
Views: 2740
Reputation: 3668
one easy way to do it is to use - (NSArray *)componentsSeparatedByString:(NSString *)separator
to make an array out of it, and then pick the second object of the array.
Upvotes: 2