如何从 openfeint 获取本地前 10 名高分

发布于 2024-10-21 04:31:36 字数 1403 浏览 1 评论 0原文

这是我的编码,用于获取本地前 10 名高分,但是,出现调试终止错误。

[OFHighScoreService getPageWithLoggedInUserForLeaderboard: theLeaderboardID onSuccess:OFDelegate(self, @selector(_scoresDownloaded:))
        onFailure:OFDelegate()];

选择器:-

- (void)_scoresDownloaded:(OFPaginatedSeries*)page
{

    NSMutableArray* highscores = nil;

    if ([page count] > 0)
    {
        if ([[page objectAtIndex:0] isKindOfClass:[OFTableSectionDescription class]])
        {
            highscores = [(OFTableSectionDescription*)[page objectAtIndex:0] page].objects;
        }
        else
        {
            highscores = page.objects;
        }
    }
   NSString *userID = [OpenFeint lastLoggedInUserName];
    for (OFHighScore* score in highscores)
    {
        ccColor3B theColor = ccBLACK;
        if ([score.user.name isEqualToString: userID] ) {
            //score now contains the users data... Do what I want with it.
                        NSLog(@"%d %@ %d", score.rank, score.user.name, score.score);
                        break;

        }

    }
}

这是我的控制台窗口错误:-

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Levelone canReceiveCallbacksNow]: unrecognized selector sent to instance 0x6af2070'
*** Call stack at first throw:

terminate called after throwing an instance of 'NSException'

this is my coding am used to get local top 10 highscore but , debugging terminated error occurs.

[OFHighScoreService getPageWithLoggedInUserForLeaderboard: theLeaderboardID onSuccess:OFDelegate(self, @selector(_scoresDownloaded:))
        onFailure:OFDelegate()];

selector:-

- (void)_scoresDownloaded:(OFPaginatedSeries*)page
{

    NSMutableArray* highscores = nil;

    if ([page count] > 0)
    {
        if ([[page objectAtIndex:0] isKindOfClass:[OFTableSectionDescription class]])
        {
            highscores = [(OFTableSectionDescription*)[page objectAtIndex:0] page].objects;
        }
        else
        {
            highscores = page.objects;
        }
    }
   NSString *userID = [OpenFeint lastLoggedInUserName];
    for (OFHighScore* score in highscores)
    {
        ccColor3B theColor = ccBLACK;
        if ([score.user.name isEqualToString: userID] ) {
            //score now contains the users data... Do what I want with it.
                        NSLog(@"%d %@ %d", score.rank, score.user.name, score.score);
                        break;

        }

    }
}

this is my console window error:-

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Levelone canReceiveCallbacksNow]: unrecognized selector sent to instance 0x6af2070'
*** Call stack at first throw:

terminate called after throwing an instance of 'NSException'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰つ倒转 2024-10-28 04:31:36

正如错误所述,您用作 OFHighScoreService 回调委托的对象无法识别选择器 canReceiveCallbacksNow。根据 OpenFeint 文档,您的回调必须实现定义此功能的 OFCallbackable 协议。只需实现该函数,例如让它始终返回 YES 即可。

As the error says, the object you are using as the callback delegate for OFHighScoreService does not recognize the selector canReceiveCallbacksNow. As per OpenFeint documentation, your callback must implement the OFCallbackable protocol which defines this. Simply implement the function, e.g. just have it return YES all the time.

雨后彩虹 2024-10-28 04:31:36

OpenFeint 仅存储给定排行榜上每个玩家的最新资格分数。没有用户会出现在排行榜上多个位置的排名。

OpenFeint only stores the latest qualifying score per player on a given leaderboard. No user would ever appear ranked at more than one slot on a leaderboard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文