Question

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?

Was it helpful?

Solution

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); 

OTHER TIPS

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

P.S. There's on more property subtitle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top