質問

I'm working with Game Center now. I've created achivements on ITC and i'm logged into Game Center. Game notice me about it. Its ok. But i have to load all achivements from Game Center and check its progress. I read Apple Reference and here is class method loadAchivementsWithCompletionHandler:.

I've got something like this, but when i call it then i haven't any results - No NSLog in console.

[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {

    if (error){
        NSLog(@"Error in syncing achievements: %@", error);
    }
    else {
        NSLog(@"Number of achievements: %d", [achievements count]);
    }
}];

How can i get achievements from Game Center correctly? I thought that achivements array should be greater than 0, but i don't know - Any NSLog isn't called.

UPDATE!!!

- (void)authenticateLocalUser:(void(^)(UIViewController *))delegate {

if (!_gameCenterAvailable) return;
NSLog(@"Authenticating local user...");
if (![GKLocalPlayer localPlayer].authenticated) {

    [[GKLocalPlayer localPlayer] setAuthenticateHandler:^(UIViewController *viewController, NSError *error) {

        if (viewController) {

            delegate((UIViewController *)viewController);
        }
        else {
            [NSThread sleepForTimeInterval:2];
            [sharedHelper syncAchivements:^(NSString *delegate) {

            }];
        }

        if (error) {
            NSLog(@"Error in AuthenticateLocalUser: %@", [error description]);
        }
    }];
} else {
    NSLog(@"Already authenticated!");
}

}

I call my above syncAchievement: method after authentication and i've got response: Number of achievements: 0 but my app has 2 achivements created. Where is the problem?

UPDATE 2!!!

I see that method loadAchievementWithCompletionHandler loads only achivements with some progress. I understood this..

役に立ちましたか?

解決

I see that method loadAchievementWithCompletionHandler: loads only achievements with some progress. I understood this.. And this is an answer. All is correctly.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top