Objective c 得分加载项游戏中心
我试图在游戏中心保存我的分数,但它不会“上传”我的分数。我正在使用代码 视图加载Objective c 得分加载项游戏中心,objective-c,Objective C,我试图在游戏中心保存我的分数,但它不会“上传”我的分数。我正在使用代码 视图加载 - (void)viewDidLoad { [super viewDidLoad]; [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { if (error == nil) { NSLog(@"Succes (viewdidload) %
- (void)viewDidLoad
{
[super viewDidLoad];
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
if (error == nil) {
NSLog(@"Succes (viewdidload) %i",counter);
} else {
NSLog(@"Fail (viewdidload) %i",counter);
}
}];
}
NSlogs输出
2012-01-06 08:46:03.804 iTouchers[313:707] Succes (viewdidload) 26
2012-01-06 08:45:52.203 iTouchers[313:707] Succes 26
有人知道这个问题吗?或者你不能在沙盒模式下添加分数?我不知道你使用的计数器类型,但你可以尝试替换以下句子:
scoreReporter.value = counter;
对于这一个:
scoreReporter.value = [[NSNumber numberWithInt:counter] longLongValue];
在我的例子中,我对变量“counter”使用类型int64_t,它工作正常
苹果要求使用这种类型 Counter是我要添加到.h文件中的分数<代码>整数计数器在子核心函数中可以执行:
int64\t score1=score
然后在:scoreReporter.value=[[NSNumber numberwhithint:score1]longvalue]中使用“score1”代码>