如何从 openfeint 获取本地前 10 名高分
这是我的编码,用于获取本地前 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如错误所述,您用作
OFHighScoreService
回调委托的对象无法识别选择器canReceiveCallbacksNow
。根据 OpenFeint 文档,您的回调必须实现定义此功能的OFCallbackable
协议。只需实现该函数,例如让它始终返回YES
即可。As the error says, the object you are using as the callback delegate for
OFHighScoreService
does not recognize the selectorcanReceiveCallbacksNow
. As per OpenFeint documentation, your callback must implement theOFCallbackable
protocol which defines this. Simply implement the function, e.g. just have it returnYES
all the time.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.