Im trying to assign a value to a double, using the following code:
double distanceFormat = [self.runsArray[indexPath.row] valueForKey:@"runDistance"];
But I keep getting the following error:
Initialising 'double' with an expression of incompatible type 'id'
However, I know the value is a double! Is there a way to do this?
Could you try with:
double distanceFormat = [[self.runsArray[indexPath.row] valueForKey:@"runDistance"] doubleValue];
If you're sure it is double I think it would work.
Use NSNumber
NSNumber *mynumber = [somedictionary valueForKey:@"runDistance"];
Once you have the nsnumber, you can convert it into whatever you want, f.ex :
int i = [mynumber intValue];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With