I am filling in some objective-c stuff that has been dropped in my lap so sorry if this is simple question. I have the following:
[self.distancesArray addObject:[NSNumber numberWithDouble:.25]];
[self.distancesArray addObject:[NSNumber numberWithDouble:3.0]]
[self.distancesArray addObject:[NSNumber numberWithDouble:10.0]];
NSLog(@"here is value: %.2f",[[self.distancesArray objectAtIndex:2] doubleValue]);
outputting:
2012-05-07 19:15:29.714 AtFoodie[30989:11903] here is value: 0.00
How would I get the value of 10?
thx
Most likely reason is that your
distancesArrayis actuallynil—it’s never being initialized. So your-addObject:calls are going toniland falling down a hole, and your-objectAtIndex:call is doing likewise and returningnil(i.e. 0).