سؤال

في دعمهم OpenFeint أعطاك هذا ، لكنني لا أفهم تمامًا. كيف يمكنني الحصول على بيانات المتصدرين ، قل أفضل 10 وأظهرها في واجهة المستخدم الخاصة بي؟

الرابط الأصلي: http://www.openfeint.com/ofdeveloper/index.php/kb/article/000028

[OFHighScoreService getPage:1 forLeaderboard:@"leaderboard_id_string" friendsOnly:NO silently:YES onSuccess:OFDelegate(self, @selector(_scoresDownloaded:)) onFailure:OFDelegate(self, @selector(_failedDownloadingScores))];

- (void)_scoresDownloaded:(OFPaginatedSeries*)page
{
    NSMutableArray* highscores = nil;

    if ([page count] > 0)
    {
        if ([[page objectAtIndex:0] isKindOfClass:[OFTableSectionDescription class]])
        {
            // NOTE: In the following line, we access "[page objectAtIndex:1]" to retrieve high scores from
            // the global leaderboard.  Using "[page objectAtIndex:0]" would retrieve scores just for the local player.
            // Older versions of OpenFeint did not break this out into 2 sections.
            highscores = [(OFTableSectionDescription*)[page objectAtIndex:1] page].objects;
        }
        else
        {
            highscores = page.objects;
        }
    }

    for (OFHighScore* score in highscores)
    {
        // ...
    }
}
- (BOOL)canReceiveCallbacksNow
{
    return YES;
} 
هل كانت مفيدة؟

المحلول

الرمز لطلب صفحة من الدرجات العالية هو السطر الأول ، أي:

[OFHighScoreService getPage:1 forLeaderboard:@"leaderboard_id_string" friendsOnly:NO silently:YES onSuccess:OFDelegate(self, @selector(_scoresDownloaded:)) onFailure:OFDelegate(self, @selector(_failedDownloadingScores))];

لقد وضعت هذا الخط في المكان الذي تريد أن تبدأ فيه الاستعلام للحصول على درجات عالية. يمكنك تغيير رقم الصفحة كما هو مطلوب. بمجرد استرداد صفحة الدرجات العالية ، فإن رد الاتصال _scoresDownloaded يسمى. يوضح لك المثال كيف يمكنك التكرار من خلال OFHighScore الكائنات في highscores مجموعة مصفوفة. سوف تحل محل التعليق // ... مع رمزك الخاص لإظهار الدرجات للاعب ، أو أي شيء آخر.

(في حالة الخطأ _failedDownloadingScores يسمى؛ يجب عليك تنفيذ ذلك لإظهار خطأ.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top