根据lynda的objective 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;
}发布于 2013-02-19 01:50:38
您没有有效的格式字符串。你要的是%i,而不是@i。
发布于 2013-02-19 01:50:46
使用NSLog(@"The score is %i", [p score]);
score返回整数,因此应使用%i或%d,而不是@i
发布于 2013-02-19 01:54:04
如果p分值返回的值是一个整数,那么它应该是
NSLog(@"The score is %i",p score);//始终使用'%‘作为格式说明符,而不是'@’
https://stackoverflow.com/questions/14942308
复制相似问题