getGameListByRankIdWithOptions:completion:
按榜单 ID 获取游戏列表
根据榜单 ID 分页获取游戏。调用前须完成 SDK 初始化;榜单 ID 可通过 getRankingsListWithOptions:completion: 获取。该方法请求 /v1/game/getListByRankId。
方法声明
objectivec
+ (void)getGameListByRankIdWithOptions:(nullable SUDOPGameListByRankIdOptions *)options
completion:(nullable void(^)(SUDOPGameListByRankIdResult *_Nullable result,
NSError *_Nullable error))completion;SUDOPGameListByRankIdOptions
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| rankId | NSString * | nil | 必传。非空榜单 ID,按字符串原样传递。 |
| pageNo | NSInteger | 0 | 页码,从 0 开始;负数按 0 处理。 |
| pageSize | NSInteger | 10 | 每页条数;小于或等于 0 时按 10 处理。 |
| language | NSString * | nil | 语言标识;nil 或空字符串使用服务端默认值。 |
completion 成功时返回 SUDOPGameListByRankIdResult,其中包含 pageNo、pageSize、total 和 records。records 使用 SUDOPGameListItem 模型。
代码示例
objectivec
SUDOPGameListByRankIdOptions *options = [[SUDOPGameListByRankIdOptions alloc] init];
options.rankId = @"popular";
options.pageNo = 0;
options.pageSize = 20;
options.language = @"zh-CN";
[SUDOP getGameListByRankIdWithOptions:options
completion:^(SUDOPGameListByRankIdResult * _Nullable result,
NSError * _Nullable error) {
if (error) {
NSLog(@"获取榜单游戏失败: %@", error.localizedDescription);
return;
}
NSLog(@"榜单游戏总数: %ld", (long)result.total);
}];注意事项
options或rankId为空、空字符串或仅包含空白字符时,SDK 会返回参数错误。
