Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 EXC_BAD_ACCESS

thanks

like image 747
ahoura Avatar asked Oct 04 '11 22:10

ahoura


1 Answers

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

http://vormplus.be/blog/article/using-nslog-to-debug-your-iphone-application

like image 144
Alan Moore Avatar answered Sep 22 '22 06:09

Alan Moore