OBJECTIVE-C: How to call/reference "reportScores:withCompletionHandler: " in ViewController.m? (GameCenter reporting scores)

ساخت وبلاگ

Vote count: 0

New iOS developer here so this is likely an easy question!

Here is the code I am using for my Game Center(See below, copied from Apple's Documentation). I have it under my ViewController.m. My question is, how do I "call" or "reference" this in the "-(void)viewDidLoad" in order to report scores to GameCenter?

My problem is I have Game Center working and authenticating, but it is not reporting any scores. I have Sandbox tued on and I have 2 different test accounts so I'm just trying to figure out how to put this final piece together. I tried the obvious [self.reportScore] but that didn't work. Sorry I am new to all this so any help would be appreciated as far as how to report a score in Game Center!

P.S. I am using Objective-C

- (void) reportScore: (int64_t) score forLeaderboardID: (NSString*) identifier
{GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier: identifier];
scoreReporter.value = score;
scoreReporter.context = 0;
NSArray *scores = @[scoreReporter];
[GKScore reportScores:scores withCompletionHandler:^(NSError *error) { //Do something interesting here.
}];
}
asked 2 mins ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 199 تاريخ : شنبه 22 خرداد 1395 ساعت: 9:33