I want to convert lat lon to CLLocationCoordinate2D
.
self.currentLocation = {.latitude = 0.0, .longitude = 0.0};
This gives me error "Expected expression".
What am I doing wrong?
I want to convert lat lon to CLLocationCoordinate2D
.
self.currentLocation = {.latitude = 0.0, .longitude = 0.0};
This gives me error "Expected expression".
What am I doing wrong?
Use CLLocationCoordinate2DMake(CLLocationDegrees latitude, CLLocationDegrees longitude)
to create the coordinates.
While you could use CLLocationCoordinate2DMake
you have to pay attention because it is available in iOS 4.0 and later only. You can try this to make it 'manually':
CLLocationCoordinate coordinate;
coordinate.latitude = 0.0;
coordinate.longitude = 0.0;
self.currentLocation = coordinate;
Your code seems to be correct. That should not throw any errors/warnings. Make sure self.currentLocation is a CLLocationCoordinate2D. Try to cast the expression like below,
self.currentLocation = (CLLocationCoordinate2D){.latitude = 0.0, .longitude = 0.0};
Alternatively you can also use CLLocationCoordinate2DMake method.
Update > Swift 4
let loc_coords = CLLocationCoordinate2DMake(47.601089,-52.740439)
For more details please have a look to apple developer website: CLLocationCoordinate2DMake
Thanks
© 2022 - 2024 — McMap. All rights reserved.