Skip to content

Get current value

Returns the current value of the counter.

- (void)getWithCounterName:(NSString * _Nonnull)counterName responseHandler:^(NSInteger)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func get(counterName: String, responseHandler: ((Int) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument                Description
counterName name of the counter to retrieve.

Example

[Backendless.shared.counters getWithCounterName:@"MyCounter" responseHandler:^(NSInteger value) {
    NSLog(@"Current value = %li", value);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];

//

id<IAtomic> myCounter = [Backendless.shared.counters ofCounterName:@"MyCounter"];
[myCounter getWithResponseHandler:^(NSInteger value) {
    NSLog(@"Current value = %li", value);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Backendless.shared.counters.get(counterName: "MyCounter", responseHandler: { value in
    print("Current value = \(value)")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

//

let myCounter = Backendless.shared.counters.of(counterName: "MyCounter")
myCounter.get(responseHandler: { value in
    print("Current value = \(value)")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})