开发者

GKScore properties warning

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"];
                 [highSco开发者_开发问答res 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!


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 -

#import <GameKit/GKScore.h>

I'd just assumed it was covered by importing the other Game Center headers... Thanks anyway!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜