我该如何调用此方法? (目标C)

时间:2011-02-23 23:16:59

标签: methods call

我有这种方法会向游戏中心报告分数:

   - (void)reportScore: (int64_t) forCategory: (NSString*) category
{
    GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
    scoreReporter.value = passedint;

    [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
        if (error != nil)
        {
            // handle the reporting error
        }
    }];
}

现在我有一个ibaction尝试调用该方法,但我无法弄清楚..

- (IBAction)uploadscore {

passedint = [[NSUserDefaults standardUserDefaults] integerForKey:@"Scoreoneplayer"];
NSLog(@"%i", passedint);

[self reportScore:(passedint)forCategory :(NSString *) category];

}

passint是我要上传到Game Center的int。如果有人可以提供帮助,那将非常感谢! :)

1 个答案:

答案 0 :(得分:0)

这应该这样做:

[self reportScore: passedint forCategory: @"Put your category here"];

您不需要在方法调用中提供类型。