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
Try this
NSLog(@"%.2f", [[self.rPrices objectAtIndex:0] floatValue]);
or alternativly just print the NSNumber
as an object
NSLog(@"%@", [self.rPrices objectAtIndex:0]);
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".
精彩评论