Does GKLeaderboard timeScope do nothing?

I am trying to make a leaderboard using GameCenter on iOS7, which only shows the ratings presented last week.

I know that with iOS7, using the timecode when opening the gamecenter view controller is outdated, but every post that I find on it suggests creating a leaderboard in the game to get around this.

We have our own leaderboards implemented in the game, which we get using loadScoresWithCompletionHandler, but the timeScope settings still do not work. Whatever I choose, I get the best result of all time for the user, and not the best pain on the last day / week.

Has anyone else found this or is working for everyone else? I confirm that the estimate is incorrect by looking at the “date” for any received GKScores.

Below is the code:

const char* szName("LeaderboardName_Week1");
NSString* pxLeaderboardName = [NSString stringWithUTF8String:szName];
GKLeaderboardTimeScope eTimeScope = GKLeaderboardTimeScopeWeek;
GKLeaderboard* leaderboardViewer = [[[GKLeaderboard alloc] init] autorelease];
if (leaderboardViewer)
{
    [leaderboardViewer setIdentifier: pxLeaderboardName];
    [leaderboardViewer setTimeScope: eTimeScope];
    [leaderboardViewer setRange: NSMakeRange(1, 100)];
    [leaderboardViewer setPlayerScope: (bFriendsOnly)?GKLeaderboardPlayerScopeFriendsOnly:GKLeaderboardPlayerScopeGlobal];

    [leaderboardViewer loadScoresWithCompletionHandler:^(NSArray* scores, NSError* error)
     {
         if (error || !scores)
         {
             NSLog(@"GameKit Score retrieval Error:\n%@", error);
         }
         else
         {
             NSLog(@"GameKit Score retrieval complete, %d scores. Retrieving player names.", (u_int)scores.count);

             GKScore* playerScore = leaderboardViewer.localPlayerScore;

             u_int uIndex2;
             for (uIndex2 = 0; uIndex2 < scores.count; ++uIndex2)
             {
                 GKScore* score = [scores objectAtIndex:uIndex2];

                 //score.date is out of the requested range at this point.
                 xEntry.m_uRank = static_cast<u_int> (score.rank);
                 xEntry.m_lScore = score.value;
                 xEntry.m_uContext = score.context;
             }
        }
    }];
}

I do it all in the sandbox. Any help appreciated!

+4
source share

Source: https://habr.com/ru/post/1547876/


All Articles