2011-04-06 74 views
1

我建立一个自定义显示的游戏中心,其工作,但我得到一个警告,对于下面的代码 -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]; 
      } 

为[thisScore等级]警告说“法“ -rank'not found(返回类型默认为'id')“。但代码工作正常。我一定会错过一些东西...

任何帮助表示赞赏!

在GKScore

回答

0

,等级为NSInteger的又名对象...

凡为呼叫%我呼吁整数..

所以..你必须调用​​得到NSInteger的对象的整数值..

+0

对不起 - 没有任何区别,仍然得到相同的警告 – SomaMan 2011-04-12 11:22:23

+0

ok .. hmm ..等级不是一种方法..它的一个属性..所以是[[thisScore.rank] intValue] – xuanweng 2011-04-13 01:55:02

0

终于找到它了 - 有点愚蠢真的,我只是没有包括在本 -

#import <GameKit/GKScore.h> 

我只是认为这是覆盖importi ng其他游戏中心标题...无论如何感谢!