I have a path, that I am retrieving in the form of a string. I would like to segregate the string into two different segments, but the method I am using gives me erroneous objects in the array.
Lets say I have path :
/Country/State/
I am retrieving it and trying to separate the two words like this:
NSArray *tempArray = [serverArray valueForKey:@"Location"];
NSArray *country;
for (NSString *string in tempArray) {
country = [string componentsSeparatedByString:@"/"];
NSLog(@"%@", country);
}
But when I do this I get two extra objects in the array when I log them :
2015-08-13 10:54:17.290 App Name[24124:0000000] (
"",
USA,
"NORTH DAKOTA",
""
)
How do I get the first string without special characters and then the second string without the special characters as well? After that I was going to use NSScanner but not sure if there is a more efficient way