开发者

How do I call this method? (Objective C)

开发者 https://www.devze.com 2023-02-13 14:55 出处:网络
I have this method which will report a score to game center: - (void)reportScore: (int64_t) forCategory: (NSString*) category

I have this method which will report a score to game center:

   - (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
        }
    }];
}

Now I have an ibaction to try to call that method but I am not able to figure it out..

- (IBAction)uploadscore {

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

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

}

passedint is the int I want to upload to Game Center. 开发者_开发问答If anyone can help, that would be greatly appreciated! :)


This should do it:

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

You shouldn't need to provide types in the method call.

0

精彩评论

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

关注公众号