LCLeaderboard
Objective-C
@interface LCLeaderboard : NSObject
/// The name of this leaderboard.
@property (nonatomic, readonly) NSString *statisticName;
/// The start positon of the query, default is `0`.
@property (nonatomic) NSInteger skip;
/// The max results count of the query, default is `20`.
@property (nonatomic) NSInteger limit;
/// The statistics of the other leaderboards will be returned, default is `nil`.
@property (nonatomic, nullable) NSArray<NSString *> *includeStatistics;
/// The version of the leaderboard, default is `0`.
@property (nonatomic) NSInteger version;
/// Whether to return the count of this leaderboard, default is `false`.
@property (nonatomic) BOOL returnCount;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/// Initializing with a name.
/// @param statisticName The name of the leaderboard.
- (instancetype)initWithStatisticName:(NSString *)statisticName;
// MARK: Update & Delete Statistics
/// Update the statistics of the current user.
/// @param statistics The statistics of the current user.
/// @param callback Result callback.
+ (void)updateCurrentUserStatistics:(NSDictionary *)statistics
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
/// Delete the statistics of the current user on the leaderboards.
/// @param statisticNames The name of the leaderboards.
/// @param callback Result callback.
+ (void)deleteCurrentUserStatistics:(NSArray<NSString *> *)statisticNames
callback:(void (^)(BOOL succeeded, NSError * _Nullable error))callback;
// MARK: Get One Statistics
/// Get the statistics of the user on the leaderboards.
/// @param userId The object id of the user.
/// @param statisticNames The name of the leaderboards.
/// @param callback Result callback.
+ (void)getStatisticsWithUserId:(NSString *)userId
statisticNames:(NSArray<NSString *> * _Nullable)statisticNames
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
/// Get the statistics of the object on the leaderboards.
/// @param objectId The object id of the object.
/// @param statisticNames The name of the leaderboards.
/// @param option The query option.
/// @param callback Result callback.
+ (void)getStatisticsWithObjectId:(NSString *)objectId
statisticNames:(NSArray<NSString *> * _Nullable)statisticNames
option:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
/// Get the statistics of the entity on the leaderboards.
/// @param entity The string of the entity.
/// @param statisticNames The name of the leaderboards.
/// @param callback Result callback.
+ (void)getStatisticsWithEntity:(NSString *)entity
statisticNames:(NSArray<NSString *> * _Nullable)statisticNames
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
// MARK: Get Group Statistics
/// Get the statistics of one group users on this leaderboard.
/// @param userIds The object id array of the users.
/// @param callback Result callback.
- (void)getStatisticsWithUserIds:(NSArray<NSString *> *)userIds
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
/// Get the statistics of one group objects on this leaderboard.
/// @param objectIds The object id array of the objects.
/// @param option The query option.
/// @param callback Result callback.
- (void)getStatisticsWithObjectIds:(NSArray<NSString *> *)objectIds
option:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
/// Get the statistics of one group entities on this leaderboard.
/// @param entities The string array of the entities.
/// @param callback Result callback.
- (void)getStatisticsWithEntities:(NSArray<NSString *> *)entities
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
// MARK: Get Rankings
/// Get rankings of the user on this leaderboard from top.
/// @param option The query option.
/// @param callback Result callback.
- (void)getUserResultsWithOption:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
/// Get rankings around one user on this leaderboard.
/// @param userId The object id of the user.
/// @param option The query option.
/// @param callback Result callback.
- (void)getUserResultsAroundUser:(NSString * _Nullable)userId
option:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
/// Get rankings of the object on this leaderboard from top.
/// @param option The query option.
/// @param callback Result callback.
- (void)getObjectResultsWithOption:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
/// Get rankings around one object on this leaderboard.
/// @param objectId The object id of the object.
/// @param option The query option.
/// @param callback Result callback.
- (void)getObjectResultsAroundObject:(NSString * _Nullable)objectId
option:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
/// Get rankings of the entity on this leaderboard from top.
/// @param callback Result callback.
- (void)getEntityResultsWithCallback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
/// Get rankings around one entity on this leaderboard.
/// @param entity The string of the entity.
/// @param callback Result callback.
- (void)getEntityResultsAroundEntity:(NSString * _Nullable)entity
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
/// Get rankings of a group of user on this leaderboard.
/// @param userIds A group of user's object id.
/// @param option The query option, see `LCLeaderboardQueryOption`.
/// @param callback Result callback.
- (void)getGroupUserResultsWithUserIds:(NSArray<NSString *> *)userIds
option:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSError * _Nullable error))callback;
/// Get rankings of a group of user around one user on this leaderboard.
/// @param userIds A group of user's object id.
/// @param userId The object id of the around user.
/// @param option The query option, see `LCLeaderboardQueryOption`.
/// @param callback Result callback.
- (void)getGroupUserResultsWithUserIds:(NSArray<NSString *> *)userIds
aroundUser:(NSString * _Nullable)userId
option:(LCLeaderboardQueryOption * _Nullable)option
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSError * _Nullable error))callback;
@end
Swift
class LCLeaderboard : NSObject
Undocumented
-
The name of this leaderboard.
Declaration
Objective-C
@property (nonatomic, readonly) NSString *_Nonnull statisticName;
Swift
var statisticName: String { get }
-
The start positon of the query, default is
0
.Declaration
Objective-C
@property (nonatomic) NSInteger skip;
Swift
var skip: Int { get set }
-
The max results count of the query, default is
20
.Declaration
Objective-C
@property (nonatomic) NSInteger limit;
Swift
var limit: Int { get set }
-
The statistics of the other leaderboards will be returned, default is
nil
.Declaration
Objective-C
@property (nonatomic, nullable) NSArray<NSString *> *includeStatistics;
Swift
var includeStatistics: [String]? { get set }
-
The version of the leaderboard, default is
0
.Declaration
Objective-C
@property (nonatomic) NSInteger version;
Swift
var version: Int { get set }
-
Whether to return the count of this leaderboard, default is
false
.Declaration
Objective-C
@property (nonatomic) BOOL returnCount;
Swift
var returnCount: Bool { get set }
-
Unavailable
Undocumented
Declaration
Objective-C
+ (instancetype)new NS_UNAVAILABLE;
-
Unavailable
Undocumented
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE;
-
Initializing with a name.
Declaration
Objective-C
- (nonnull instancetype)initWithStatisticName:(nonnull NSString *)statisticName;
Swift
init(statisticName: String)
Parameters
statisticName
The name of the leaderboard.
-
Update the statistics of the current user.
Declaration
Objective-C
+ (void)updateCurrentUserStatistics:(nonnull NSDictionary *)statistics callback: (nonnull void (^)( NSArray<LCLeaderboardStatistic *> *_Nullable, NSError *_Nullable))callback;
Swift
class func updateCurrentUserStatistics(_ statistics: [AnyHashable : Any], callback: @escaping ([LCLeaderboardStatistic]?, Error?) -> Void)
Parameters
statistics
The statistics of the current user.
callback
Result callback.
-
Delete the statistics of the current user on the leaderboards.
Declaration
Objective-C
+ (void) deleteCurrentUserStatistics:(nonnull NSArray<NSString *> *)statisticNames callback: (nonnull void (^)(BOOL, NSError *_Nullable))callback;
Swift
class func deleteCurrentUserStatistics(_ statisticNames: [String], callback: @escaping (Bool, Error?) -> Void)
Parameters
statisticNames
The name of the leaderboards.
callback
Result callback.
-
Get the statistics of the user on the leaderboards.
Declaration
Objective-C
+ (void)getStatisticsWithUserId:(nonnull NSString *)userId statisticNames:(NSArray<NSString *> *_Nullable)statisticNames callback: (nonnull void (^)( NSArray<LCLeaderboardStatistic *> *_Nullable, NSError *_Nullable))callback;
Swift
class func getStatisticsWithUserId(_ userId: String, statisticNames: [String]?, callback: @escaping ([LCLeaderboardStatistic]?, Error?) -> Void)
Parameters
userId
The object id of the user.
statisticNames
The name of the leaderboards.
callback
Result callback.
-
Get the statistics of the object on the leaderboards.
Declaration
Objective-C
+ (void)getStatisticsWithObjectId:(nonnull NSString *)objectId statisticNames:(NSArray<NSString *> *_Nullable)statisticNames option:(LCLeaderboardQueryOption *_Nullable)option callback: (nonnull void (^)( NSArray<LCLeaderboardStatistic *> *_Nullable, NSError *_Nullable))callback;
Swift
class func getStatisticsWithObjectId(_ objectId: String, statisticNames: [String]?, option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardStatistic]?, Error?) -> Void)
Parameters
objectId
The object id of the object.
statisticNames
The name of the leaderboards.
option
The query option.
callback
Result callback.
-
Get the statistics of the entity on the leaderboards.
Declaration
Objective-C
+ (void)getStatisticsWithEntity:(nonnull NSString *)entity statisticNames:(NSArray<NSString *> *_Nullable)statisticNames callback: (nonnull void (^)( NSArray<LCLeaderboardStatistic *> *_Nullable, NSError *_Nullable))callback;
Swift
class func getStatisticsWithEntity(_ entity: String, statisticNames: [String]?, callback: @escaping ([LCLeaderboardStatistic]?, Error?) -> Void)
Parameters
entity
The string of the entity.
statisticNames
The name of the leaderboards.
callback
Result callback.
-
Get the statistics of one group users on this leaderboard.
Declaration
Objective-C
- (void)getStatisticsWithUserIds:(nonnull NSArray<NSString *> *)userIds callback: (nonnull void (^)( NSArray<LCLeaderboardStatistic *> *_Nullable, NSError *_Nullable))callback;
Swift
func getStatisticsWithUserIds(_ userIds: [String], callback: @escaping ([LCLeaderboardStatistic]?, Error?) -> Void)
Parameters
userIds
The object id array of the users.
callback
Result callback.
-
Get the statistics of one group objects on this leaderboard.
Declaration
Objective-C
- (void)getStatisticsWithObjectIds:(nonnull NSArray<NSString *> *)objectIds option:(LCLeaderboardQueryOption *_Nullable)option callback: (nonnull void (^)( NSArray<LCLeaderboardStatistic *> *_Nullable, NSError *_Nullable))callback;
Swift
func getStatisticsWithObjectIds(_ objectIds: [String], option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardStatistic]?, Error?) -> Void)
Parameters
objectIds
The object id array of the objects.
option
The query option.
callback
Result callback.
-
Get the statistics of one group entities on this leaderboard.
Declaration
Objective-C
- (void)getStatisticsWithEntities:(nonnull NSArray<NSString *> *)entities callback: (nonnull void (^)( NSArray<LCLeaderboardStatistic *> *_Nullable, NSError *_Nullable))callback;
Swift
func getStatisticsWithEntities(_ entities: [String], callback: @escaping ([LCLeaderboardStatistic]?, Error?) -> Void)
Parameters
entities
The string array of the entities.
callback
Result callback.
-
Get rankings of the user on this leaderboard from top.
Declaration
Objective-C
- (void)getUserResultsWithOption:(LCLeaderboardQueryOption *_Nullable)option callback:(nonnull void (^)( NSArray<LCLeaderboardRanking *> *_Nullable, NSInteger, NSError *_Nullable))callback;
Swift
func getUserResults(with option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardRanking]?, Int, Error?) -> Void)
Parameters
option
The query option.
callback
Result callback.
-
Get rankings around one user on this leaderboard.
Declaration
Objective-C
- (void)getUserResultsAroundUser:(NSString *_Nullable)userId option:(LCLeaderboardQueryOption *_Nullable)option callback:(nonnull void (^)( NSArray<LCLeaderboardRanking *> *_Nullable, NSInteger, NSError *_Nullable))callback;
Swift
func getUserResultsAroundUser(_ userId: String?, option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardRanking]?, Int, Error?) -> Void)
Parameters
userId
The object id of the user.
option
The query option.
callback
Result callback.
-
Get rankings of the object on this leaderboard from top.
Declaration
Objective-C
- (void)getObjectResultsWithOption:(LCLeaderboardQueryOption *_Nullable)option callback: (nonnull void (^)( NSArray<LCLeaderboardRanking *> *_Nullable, NSInteger, NSError *_Nullable))callback;
Swift
func getObjectResults(with option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardRanking]?, Int, Error?) -> Void)
Parameters
option
The query option.
callback
Result callback.
-
Get rankings around one object on this leaderboard.
Declaration
Objective-C
- (void)getObjectResultsAroundObject:(NSString *_Nullable)objectId option:(LCLeaderboardQueryOption *_Nullable)option callback: (nonnull void (^)( NSArray<LCLeaderboardRanking *> *_Nullable, NSInteger, NSError *_Nullable))callback;
Swift
func getObjectResultsAroundObject(_ objectId: String?, option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardRanking]?, Int, Error?) -> Void)
Parameters
objectId
The object id of the object.
option
The query option.
callback
Result callback.
-
Get rankings of the entity on this leaderboard from top.
Declaration
Objective-C
- (void)getEntityResultsWithCallback: (nonnull void (^)(NSArray<LCLeaderboardRanking *> *_Nullable, NSInteger, NSError *_Nullable))callback;
Swift
func getEntityResults(callback: @escaping ([LCLeaderboardRanking]?, Int, Error?) -> Void)
Parameters
callback
Result callback.
-
Get rankings around one entity on this leaderboard.
Declaration
Objective-C
- (void)getEntityResultsAroundEntity:(NSString *_Nullable)entity callback: (nonnull void (^)( NSArray<LCLeaderboardRanking *> *_Nullable, NSInteger, NSError *_Nullable))callback;
Swift
func getEntityResultsAroundEntity(_ entity: String?, callback: @escaping ([LCLeaderboardRanking]?, Int, Error?) -> Void)
Parameters
entity
The string of the entity.
callback
Result callback.
-
Get rankings of a group of user on this leaderboard.
Declaration
Objective-C
- (void) getGroupUserResultsWithUserIds:(nonnull NSArray<NSString *> *)userIds option:(LCLeaderboardQueryOption *_Nullable)option callback: (nonnull void (^)( NSArray<LCLeaderboardRanking *> *_Nullable, NSError *_Nullable))callback;
Swift
func getGroupUserResults(withUserIds userIds: [String], option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardRanking]?, Error?) -> Void)
Parameters
userIds
A group of user’s object id.
option
The query option, see
LCLeaderboardQueryOption
.callback
Result callback.
-
Get rankings of a group of user around one user on this leaderboard.
Declaration
Objective-C
- (void) getGroupUserResultsWithUserIds:(nonnull NSArray<NSString *> *)userIds aroundUser:(NSString *_Nullable)userId option:(LCLeaderboardQueryOption *_Nullable)option callback: (nonnull void (^)( NSArray<LCLeaderboardRanking *> *_Nullable, NSError *_Nullable))callback;
Swift
func getGroupUserResults(withUserIds userIds: [String], aroundUser userId: String?, option: LCLeaderboardQueryOption?, callback: @escaping ([LCLeaderboardRanking]?, Error?) -> Void)
Parameters
userIds
A group of user’s object id.
userId
The object id of the around user.
option
The query option, see
LCLeaderboardQueryOption
.callback
Result callback.