I have an NSString with the value of:
NSString *combined = "10014, 40.734, -74.0053";
I would like to break this string where there are commas into three NSStrings that called bZip, bLat, and bLon so that the values would be like below:
bZip = 10014
bLat = 40.734
bLon = -74.0053
I would then like to use the bLat and bLon coordinates to update the center location on a MapView. The MapView pulls data from a JSON feed and plots the markers out, but I need to re-focus the map on the coordinates that were saved in the values for bLat and bLon.
I am assuming that I need to make this change after the line:
[self.mapView1 addAnnotations:newAnnotations];
Does anyone know how to help me make this happen? Thank you all!
NSData *data = [NSData dataWithContentsOfURL:url];
NSError *error;
NSArray *array = [NSJSONSerialization JSONObjectWithData:data
options:0
error:&error];
CLLocationCoordinate2D location;
NSMutableArray *newAnnotations = [NSMutableArray array];
MapViewAnnotation *newAnnotation;
for (NSDictionary *dictionary in array)
{
location.latitude = [dictionary[@"placeLatitude"] doubleValue];
location.longitude = [dictionary[@"placeLongitude"] doubleValue];
newAnnotation = [[MapViewAnnotation alloc] initWithTitle:dictionary[@"name"]
andCoordinate:location];
[newAnnotations addObject:newAnnotation];
}
[self.mapView1 addAnnotations:newAnnotations];