Reputation: 1360
I have a NSArray with numbers and I want to get the value of an item of the array and assign it to a double. In my attempt of 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 you,
F.
Upvotes: 6
Views: 5523
Reputation: 3657
You can use this code
double lat = [[storeList.latitudes objectAtIndex:i] doubleValue];
Thank you
Upvotes: 2
Reputation: 4159
If you say that your array is consisting of number (NSNumber class), that you may should get the value next way:
double lat = [[storeList.latitudes objectAtIndex:i] doubleValue];
Upvotes: 15
Reputation: 723598
You cannot cast an NSNumber
object to a primitive double
type value. Use the doubleValue
method of NSNumber
instead, like this:
lat = [[storesList.latitudes objectAtIndex:i] doubleValue];
Upvotes: 7