0

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\]
     }

enter image description here this is the error what i'm getting...
thank in advance

goku
  • 169
  • 1
  • 13

1 Answers1

1

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;
Kjuly
  • 34,476
  • 22
  • 104
  • 118