KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want get my Current City name in my iPhone App. I'm currently getting the latitude and longitude using CLLocationManager and than i am passing my coordinates into CLGeocoder. CLGeocoder * geoCoder = [[CLGeocoder alloc] init]; [geoCoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { for (CLPlacemark * placemark in placemarks) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Current City" message:[NSString stringWithFormat:@"Your Current City:%@",[placemark locality]] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil]; [alert show]; } }]; This is working fine in iOS 5.0 but not working in iOS 4.3. As an alternative, I started using the Google Web service -(void)findLocationFor:(NSString *)latitudeStr andLontitude:(NSString *)longtitudeStr{ if ([self connectedToWiFi]){ float latitude = [latitudeStr floatValue]; float longitude = [longtitudeStr floatValue]; NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:@"%f,%f", latitude, longitude], @"latlng", nil]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://maps.googleapis.com/maps/api/geocode/json"]]; [parameters setValue:@"true" forKey:@"sensor"]; [parameters setValue:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode] forKey:@"language"]; NSMutableArray *paramStringsArray = [NSMutableArray arrayWithCapacity:[[parameters allKeys] count]]; for(NSString *key in [parameters allKeys]) { NSObject *paramValue = [parameters valueForKey:key]; [paramStringsArray addObject:[NSString stringWithFormat:@"%@=%@", key, paramValue]]; } NSString *paramsString =
Tags (comma-separated)
Save Edits
Cancel