-(CLLocationCoordinate2D) addressLocation:(NSString *)address {
NSString *urlString = [NSString stringWithFormat:@”http://maps.google.com/maps/geo?q=%@&output=csv”,
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSArray *listItems = [locationString componentsSeparatedByString:@”,”];

double _latitude = 0.0;
double _longitude = 0.0;

if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@”200″]) {
_latitude = [[listItems objectAtIndex:2] doubleValue];
_longitude = [[listItems objectAtIndex:3] doubleValue];
}
else {
//Show error
}
CLLocationCoordinate2D _location;
_location.latitude = _latitude;
_location.longitude = _longitude;

//NSLog(@”%f – %f”, latitude, longitude);

return _location;
}

Advertisements