searchGamesWithOptions:completion:
Search Games
Searches for games by keyword and returns cursor-paginated results. Initialize the SDK before calling this method. It requests /v1/game/search.
Method Declaration
objectivec
+ (void)searchGamesWithOptions:(nullable SUDOPGameSearchOptions *)options
completion:(nullable void(^)(SUDOPGameSearchResult *_Nullable result,
NSError *_Nullable error))completion;SUDOPGameSearchOptions
| Field | Type | Default | Description |
|---|---|---|---|
| keyword | NSString * | nil | Required. A non-empty search term; leading and trailing whitespace is removed. |
| language | NSString * | nil | Language identifier such as en-US. nil or empty uses the server default. |
| cursor | NSString * | nil | Cursor returned by the previous page. Use nil for the first request. |
| pageSize | NSInteger | 10 | Records per page. Values less than or equal to 0 are treated as 10. |
Result Models
| Field | Type | Description |
|---|---|---|
| list | NSArray<SUDOPGameSearchItem *> * | Games in the current page. Each item includes gameId, localized gameName, and localized icon. |
| pagination | SUDOPGameSearchPagination * | Pagination data containing total, hasMore, and nullable nextCursor. |
Example
objectivec
SUDOPGameSearchOptions *options = [[SUDOPGameSearchOptions alloc] init];
options.keyword = @"party";
options.language = @"en-US";
options.pageSize = 20;
[SUDOP searchGamesWithOptions:options
completion:^(SUDOPGameSearchResult * _Nullable result,
NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to search games: %@", error.localizedDescription);
return;
}
NSLog(@"Returned: %ld, has more: %@",
(long)result.list.count,
result.pagination.hasMore ? @"YES" : @"NO");
}];Notes
- A
niloptions object or a missing, empty, or whitespace-onlykeywordreturns a parameter error. - To load another page, pass the previous page's
nextCursorunchanged as the next request'scursor. - The callback runs on the main thread.
