格式字符串未使用的数据参数

时间:2013-02-18 17:48:39

标签: ios objective-c c xcode

关于lynda目标的视频c我已经介绍了一个小问题,

#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;
}

4 个答案:

答案 0 :(得分:10)

您没有有效的格式字符串。您想要%i,而不是@i

答案 1 :(得分:4)

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

score返回整数,因此%i%d不应使用@i

答案 2 :(得分:2)

如果[p score]返回的值是整数,那么它应该是
NSLog(@&#34;得分%i &#34;,[p得分]); //始终使用&#39;%&#39;格式说明符不是&#39; @&#39;

答案 3 :(得分:2)

格式字符串应使用%i而不是@i

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