Search code examples
ioscllocation

CLLocationDegrees with an expression of incompatible type 'double'


The topic says everything. why i get this error message at this 2 lines?

NSArray *coordinates = [locationDetails[@"coordinates"] componentsSeparatedByString:@","];
CLLocationDegrees *lat = [coordinates[1] doubleValue]; //here is the red arrow <----

and exactly this message will appear:

Initializing 'CLLocationDegrees *'(aka 'double *') with an expression of incompatible type 'double'


Solution

  • Change this:

    CLLocationDegrees *lat = [coordinates[1] doubleValue];
    

    to:

    CLLocationDegrees lat = [coordinates[1] doubleValue];
    

    Get rid of the asterisk. CLLocationDegrees is not a class, it is a typedef for double (a basic type).