Data argument not used by format string

Following videos on lynda c facility I ran a little problem,

#import <Foundation/Foundation.h>
#import "Player.h"

int main(int argc, const char * argv[])
{

@autoreleasepool {


    Player *p = [[Player alloc] init];
    NSLog(@"The score is @i", [p score]); <-- Data argument not used by format string

}
return 0;
}

      

+3


source to share


4 answers


You don't have a valid format string. You want %i

, not @i

.



+10


source


Use NSLog(@"The score is %i", [p score]);



score

returns an integer so %i

or %d

should not be used@i

+4


source


If the value returned by [p score] is an integer, it must be NSLog (@ "Score % i ", [p score]); // Always use '%' as a format specifier, not '@'

+2


source


The format string should be used %i

instead of @i

:

NSLog(@"The score is %i", [p score]);

      

+2


source







All Articles