NSLog not working with float?

I am trying to do nslog by float value using:

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

and I also tried:

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

but it does not work! any thoughts why this won't work? the error i get is EXC_BAD_ACCESS

thanks

+7
source share
2 answers

% @ is designed to work with an object; float is not an object. To attempt a floating point:

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

Here is a useful article.

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

+36
source

EXC_BAD_ACCESS always means that you are accessing an already released object. @x deals with objects. So make sure your variable "x" is the object that was alive.

0
source

All Articles