GKScore 属性警告
我正在为游戏中心构建一个自定义显示,它可以工作,但我收到以下代码的警告 -
NSMutableArray *playerIDsArray = [[NSMutableArray alloc] init];
[highScores removeAllObjects];
for (GKScore *thisScore in scores)
{
NSMutableDictionary *thisEntry = [[NSMutableDictionary alloc] init];
NSString *playerID = [thisScore playerID];
[thisEntry setObject:playerID forKey:@"playerID"];
[playerIDsArray addObject:playerID];
[thisEntry setObject:[NSNumber numberWithInt:(int)[thisScore value]] forKey:@"value"];
[highScores setObject:thisEntry forKey:[NSString stringWithFormat:@"%i",[thisScore rank]]]; // warning here
[thisEntry release];
}
[thisScorerank] 的警告说“找不到方法'-rank'(返回类型默认为'id') )”。不过,该代码运行良好。我一定错过了一些东西...
任何帮助表示赞赏!
I'm building a custom display for Game Center, which works, except I'm getting a warning for the following code -
NSMutableArray *playerIDsArray = [[NSMutableArray alloc] init];
[highScores removeAllObjects];
for (GKScore *thisScore in scores)
{
NSMutableDictionary *thisEntry = [[NSMutableDictionary alloc] init];
NSString *playerID = [thisScore playerID];
[thisEntry setObject:playerID forKey:@"playerID"];
[playerIDsArray addObject:playerID];
[thisEntry setObject:[NSNumber numberWithInt:(int)[thisScore value]] forKey:@"value"];
[highScores setObject:thisEntry forKey:[NSString stringWithFormat:@"%i",[thisScore rank]]]; // warning here
[thisEntry release];
}
The warning for [thisScore rank] says "Method '-rank' not found (return type defaults to 'id')". The code works fine, however. I must be missing something...
Any help appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 GKScore 中,rank 是一个 NSInteger 又名对象...
而调用 %i 是调用整数..
因此..您必须调用
[[thisScorerank]intValue]
来获取 NSInteger 的整数值目的..in GKScore, rank is a NSInteger aka Object...
Where as calling %i is calling integer..
hence.. You must call
[[thisScore rank]intValue]
to get the integer Value of the NSInteger Object..终于弄清楚了 - 真的有点傻,我只是没有包含这个 -
我只是假设它是通过导入其他游戏中心标头来覆盖的......无论如何谢谢!
Finally figured it out - bit daft really, I just hadn't included this -
I'd just assumed it was covered by importing the other Game Center headers... Thanks anyway!