我正在尝试在我的应用程序中实现 Game Center。
我用了这个教程
在我的视图控制器中,我有:
- (IBAction) submitScore
{
if(self.currentScore > 0)
{
[_gameCenterManager reportScore: self.currentScore forCategory: self.currentLeaderBoard];
}
}
在 GameCenterManager.m 我有:
- (void) reportScore: (int64_t) score forCategory: (NSString*) category
{
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler: ^(NSError *error)
{
MyLog(@"scoreReporter %@", scoreReporter);
[self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error];
}];
}
- (void) callDelegateOnMainThread: (SEL) selector withArg: (id) arg error: (NSError*) err
{
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[self callDelegate: selector withArg: arg error: err];
});
}
- (void) callDelegate: (SEL) selector withArg: (id) arg error: (NSError*) err
{
MyLog(@"selector %@", selector);
MyLog(@"delegate %@", delegate);
assert([NSThread isMainThread]);
if([delegate respondsToSelector: selector])
{
if(arg != NULL)
{
[delegate performSelector: selector withObject: arg withObject: err];
}
else
{
[delegate performSelector: selector withObject: err];
}
}
else
{
NSLog(@"Missed Method");
}
}}
在我的日志中,我总是写“错过的方法”。我来报告第一个分数(例如:35),但现在,不可能报告新分数(例如:100)。
NSlog 是:
2013-01-25 20:21:25.847 isam[37958:c07] -[GameCenterManager reportScore:forCategory:]_block_invoke_1 scoreReporter <GKScore: 0xb19a3f0>player:G:1677639845 rank:0 date:2013-01-25 19:21:25 +0000 value:50 formattedValue:(null) context:0x0
2013-01-25 20:21:25.847 isam[37958:c07] -[GameCenterManager callDelegate:withArg:error:] selector scoreReported:
2013-01-25 20:21:25.848 isam[37958:c07] -[GameCenterManager callDelegate:withArg:error:] delegate <GameViewController_iPhone: 0xb16d120>
2013-01-25 20:21:25.848 isam[37958:c07] Missed Method
我想我在谷歌上阅读了关于我的问题的所有主题,但我没有找到正确的解决方案。