Reputation: 17591
I have this nsstring
Manhattan, New York, Stati Uniti
I want leave all space and I can use replacestring with @"", it's ok for me; my very problem is that I want put all element separate by commas in an array, is it possible?
for example the array'll be array = [Manhattan] [New York] [Stati Uniti]
thanks
Upvotes: 1
Views: 61
Reputation: 8505
Use NSString
's componentsSeparatedByString
:
NSString *list = @"Manhattan, New York, Stati Uniti";
NSArray *cities = [list componentsSeparatedByString:@", "];
cities
now holds: { @"Manhattan", @"New York", @"Stati Uniti" }
Upvotes: 4
Reputation: 879
Try something like this
NSArray *newArray = [stateString componentsSeparatedByString:@", "];
Upvotes: 3