Reputation: 1004
In the root model I have:
[self.rPrices replaceObjectAtIndex:0
withObject:[NSNumber numberWithFloat:(float)nR4]];
NSLog(@"%.2f", [self.rPrices objectAtIndex:0]);
where rPrices is NSMutableArray
.
nR4 is not zero but the above NSLog(...);
displays zero.
Thanks
Upvotes: 2
Views: 188
Reputation: 51374
NSNumber is an object. So you can't print it using float format specifier "%f".
You can use "%@" or get the float value from it using -floatValue
and print it using "%f".
Upvotes: 2
Reputation: 38728
Try this
NSLog(@"%.2f", [[self.rPrices objectAtIndex:0] floatValue]);
or alternativly just print the NSNumber
as an object
NSLog(@"%@", [self.rPrices objectAtIndex:0]);
Upvotes: 9