NSLog doesnt work with float?
19,910
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
Related videos on Youtube
Author by
ahoura
Updated on June 04, 2022Comments
-
ahoura almost 2 years
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
-
Zaky German over 12 yearsYou must be confusing NSFloat with CGFloat, which is just defined as 'float' and not an object.. Unless there's an NSFloat object i'm not aware of?
-
vikingosegundo over 12 yearsThere is nothing like NSFloat. stackoverflow.com/questions/6702923/…
-
ughoavgfhw over 12 yearsFor information on other specifiers, see Apple's String Format Specifiers Guide.
-
vikingosegundo over 12 yearsAnd NSInteger and NSUInteger aren't objects neither.
-
omz over 12 years
CGFloat
is actually adouble
on 64 bit and afloat
on 32 bit architectures. -
Yuanhai Shi over 12 yearsIn xcode4, Edit Scheme->Arguments->Environment variables,add NSZombieEnabled,set it to YES.U will locate the mistake.