Simple: NSArray object for Double?

I have an NSArray with numbers, and I want to get the value of an array element and assign it to a double. In my attempt at simple casting:

lat = (double)[storesList.latitudes objectAtIndex:i];

I get the error: "Pointer value used where a floating point value was expected."

Please, help!

Thank,

F.

+5
source share
3 answers

If you say that your array consists of a number (class NSNumber), you can get the following value:

double lat = [[storeList.latitudes objectAtIndex:i] doubleValue];
+14
source

You cannot use an object NSNumberfor a primitive type value double. Use a method doubleValue NSNumber, for example:

lat = [[storesList.latitudes objectAtIndex:i] doubleValue];
+6
source

double lat = [[storeList.latitudes objectAtIndex:i] doubleValue];

+1

All Articles