Reputation: 59
I have a small doubt on splitting a string into substring. I want to display State and Country name in one label. i have a string in a service coming from json file "FullAddress": "New Windsor,New York,USA". i want only New York,USA to display in a label.
Upvotes: 0
Views: 92
Reputation: 246
Please Use this code it will be help you out
NSString *fullAddress=@"New Windsor,New York,USA";
NSRange range=[fullAddress rangeOfString:@","];
if (range.location!=NSNotFound) {
NSString *string=[fullAddress substringFromIndex:range.location+range.length];//this is address you want
NSLog(@"%@",string);
}
Upvotes: 0
Reputation: 547
Use this and get your desire String
from Array
element 1 and 2
NSArray *strings = [FullAddress componentsSeparatedByString:@","];
Upvotes: 4