#import <CoreLocation/CoreLocation.h>
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCodes = [locale objectForKey:NSLocaleCountryCode];
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCodes = [locale objectForKey:NSLocaleCountryCode];
NSLog(@"%@",countryCodes);
NSString *countryName = [locale displayNameForKey:NSLocaleCountryCode value:countryCodes];
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
[locationManager startUpdatingLocation];
CLLocationManager *locationManager;
@property (nonatomic, retain) CLLocationManager *locationManager;
@synthesize locationManager;
@interface RootViewController : UIViewController <CLLocationManagerDelegate>
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocation *location = newLocation;
NSLog(@"Our current Latitude is %f",location.coordinate.latitude);
NSLog(@"Our current Longitude is %f",location.coordinate.longitude);
float currentLatitude = location.coordinate.latitude;
float currentLongitude = location.coordinate.longitude;
[locationManager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"There is an error updating the location");
}
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)