title: How to get current location using CLLocationManager in iOS
body: <p>I can already find the current location using latitude and longitude, but I would also like to be able to find the current location given a zip code.</p>
  
  <p>Here is what I have so far:</p>
  
  <p><strong>.h</strong></p>
  
  <pre><code>#import &lt;MapKit/MapKit.h&gt;
  #import &lt;UIKit/UIKit.h&gt;
  #import &lt;CoreLocation/CoreLocation.h&gt;
  
  
  @interface ViewController : UIViewController&lt;CLLocationManagerDelegate&gt;
  
  {
  
  CLLocationManager *locationManager;
   CLLocation *currentLocation;
  
      IBOutlet UILabel *label1;
      IBOutlet UILabel *lable2;
  
  }
  @property (weak, nonatomic) IBOutlet MKMapView *myMapview;
  @property (weak, nonatomic) IBOutlet UILabel *label2;
  @property (weak, nonatomic) IBOutlet UILabel *lable1;
  @end
  </code></pre>
  
  <p><strong>.m</strong></p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  
  {
  
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
      locationManager = [[CLLocationManager alloc]init];
  
  
  
      locationManager.delegate = self;
  
  
      locationManager.distanceFilter = kCLDistanceFilterNone;
  
  
      locationManager.desiredAccuracy = kCLLocationAccuracyBest;
  
  
      [locationManager startUpdatingLocation];
  
  
      _myMapview.showsUserLocation = YES;
  
      [self-&gt;locationManager startUpdatingLocation];
  
  
  
      CLLocation *location = [locationManager location];
  
  
      CLLocationCoordinate2D coordinate = [location coordinate];
  
  
      NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude];
      NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];
  
      //NSLog(@”dLatitude : %@”, latitude);
      //NSLog(@”dLongitude : %@”,longitude);
      NSLog(@"MY HOME :%@", latitude);
      NSLog(@"MY HOME: %@ ", longitude);
  
  }
  
  #pragma mark CLLocationManager Delegate
  - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
  {
      currentLocation = [locations objectAtIndex:0];
      [locationManager stopUpdatingLocation];
  
      [self-&gt;locationManager stopUpdatingLocation];
  
  
  
  
      NSLog(@"my latitude :%f",currentLocation.coordinate.latitude);
  
      NSLog(@"my longitude :%f",currentLocation.coordinate.longitude);
      label1.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
      lable2.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
  
  
      NSLog(@"Detected Location : %f, %f", currentLocation.coordinate.latitude, currentLocation.coordinate.longitude);
      CLGeocoder *geocoder = [[CLGeocoder alloc] init] ;
      [geocoder reverseGeocodeLocation:currentLocation
                     completionHandler:^(NSArray *placemarks, NSError *error)
       {
                         if (error)
                         {
                             NSLog(@"Geocode failed with error: %@", error);
                             return;
                         }
  
  NSLog(@"Monday");
                         CLPlacemark *placemark = [placemarks objectAtIndex:0];
                         NSLog(@"placemark.ISOcountryCode %@",placemark.ISOcountryCode);
  
                     }];
  }
  - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
  {
      NSLog(@"didUpdateToLocation: %@", newLocation);
      CLLocation *currentLocation = newLocation;
  
      if (currentLocation != nil)
      {
  
      label1.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
      lable2.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
      }
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  @end
  </code></pre>