Console does not show me the right value while using NSLog to show a placeholder of an Array
I try to print the second placeholder of an Array in the console with the following code:
NSArray *europeTransaction = [[NSArray alloc] initWithObjects:europeDollarTransaction, [NSNumber alloc] initWithDouble: 200.00], nil]; NSLog(@"I'm displaying the second placeholders value in the NSArray %.2f", europeTransaction );
The console shows me a value of 0.00, while it should give me a value of 200. What's wrong with the code?
The format specifier %f is used for floats, while you are passing an NSNumber instance. Either use the specifier %@ or ask the NSNumber for its float representation:
NSLog(@"I'm displaying the second placeholders value in the NSArray %.2f", [europeTransaction floatValue]);