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 [1]);
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
%fis used for floats, while you are passing anNSNumberinstance. Either use the specifier%@or ask theNSNumberfor its float representation: