0

I am able to get the longitude and altitude of user's current location but, not the name of location . I used userLocation property as below:

NSLog(@"Current location=%@",mapView.userLocation);

but, it gives me output as Current location=<MKUserLocation: 0x1f59e8c0>

I want to get the string value of that location instead of 0x1f59e8c0. How to do this?

Matt
  • 74,352
  • 26
  • 153
  • 180
stack
  • 951
  • 3
  • 9
  • 23

2 Answers2

1
NSLog(@"Current location %@",mapView.userLocation.title); 

P.S. There's on more property subtitle

Hemang
  • 26,840
  • 19
  • 119
  • 186
1

Starting at the MKMapView documentation: http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html

You can follow the chain down to find the longitude is part of a CLLocationCoordinate2D (and is a double) http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CoreLocationDataTypesRef/Reference/reference.html#//apple_ref/doc/c_ref/CLLocationCoordinate2D

NSLog(@"Current longitude = %f",mapView.userLocation.location.coordinate.longitude); 
Craig
  • 8,093
  • 8
  • 42
  • 74