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

Share:
19,910

Related videos on Youtube

ahoura
Author by

ahoura

Updated on June 04, 2022

Comments

  • ahoura
    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
    Zaky German over 12 years
    You 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
    vikingosegundo over 12 years
    There is nothing like NSFloat. stackoverflow.com/questions/6702923/…
  • ughoavgfhw
    ughoavgfhw over 12 years
    For information on other specifiers, see Apple's String Format Specifiers Guide.
  • vikingosegundo
    vikingosegundo over 12 years
    And NSInteger and NSUInteger aren't objects neither.
  • omz
    omz over 12 years
    CGFloat is actually a double on 64 bit and a float on 32 bit architectures.
  • Yuanhai Shi
    Yuanhai Shi over 12 years
    In xcode4, Edit Scheme->Arguments->Environment variables,add NSZombieEnabled,set it to YES.U will locate the mistake.

Related