I got the longitude and latitude values and i saved it in a label and it was easily displayed in my application but i want the current location details, mainly the name of the place.
I used MKReverseGeocoder. i did this code
- (void)locationUpdate:(CLLocation *)location
{
CLLocationCoordinate2D coord;
coord.longitude=[NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude];
MKReverseGeocoder *geocoder=[[MKReverseGeocoder alloc]initWithCoordinate:coord];
[geocoder setDelegate:self];
[geocoder start];
latlbl.text = [NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude];
lonlbl.text = [NSString stringWithFormat:@"LONGITUDE: %f", location.coordinate.longitude];
//txtlocate.text = [location description];
}
![-(void)reverseGeocoder:(MKReverseGeocoder)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(@"%@",\[placemark addressDictionary\]
}
this is the error what i'm getting...
thank in advance
The error is clear:
Assigning to 'CLLocationCoordinate2D' (aka 'double') from incompatible type 'id'
coord
is CLLocationCoordinate2D
type:
typedef struct {
CLLocationDegrees latitude;
CLLocationDegrees longitude;
} CLLocationCoordinate2D;
And latitude
, longitude
are CLLocationDegrees:
typedef double CLLocationDegrees;
So you cannot assign NSString (it's an id
type either) object to coord.longitude
nor coord.latitude
.
EDIT:
You should do it like:
coord.longitude = location.coordinate.latitude;