ahoura ahoura - 1 year ago 100
Objective-C Question

NSLog doesnt work with float?

I am trying to do nslog on a float value using :

NSLog(@"THE LOG SCORE : %@", x);

and I have also tried :

NSLog(@"THE LOG SCORE : %@", [NSString stringWithFormat:@"%@", x]);

but it doesnt work! any thoughts why it wouldnt work? the error I get is


Answer Source

The %@ is intended to work on an object, a float is not an object. To do a float try:

NSLog(@"THE LOG SCORE : %f", x);

Here's a helpful article


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download