2011-04-06 57 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其他遊戲中心標題...無論如何感謝!