Skip to content

Length

Description

This operation counts the number of elements in the set and returns the total.

Method

[[[Backendless.shared hive:(NSString *)hiveName] setStore:(NSString *)keyName] lengthWithResponseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).setStore(keyName: String).length(responseHandler: ((Int) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a set. String value.

Return Value

The number of items stored in the set

Example

The example below returns the number of items stored in the "cars" set.

[[[Backendless.shared hive:@"transport"] setStore:@"cars"] lengthWithResponseHandler:^(NSInteger response) {
    // handle response
} errorHandler:^(Fault *fault) {
    // handle error
}];
Backendless.shared.hive("transport").setStore("cars").length(responseHandler: { response in
    // handle response
}, errorHandler: { fault in
    // handle error
})

where:

Argument                Description
"transport" Name of a hive where the operation is performed.
"cars" Key name identifying a set.

Codeless Reference

set_api_get_key_items_count

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key names A list containing key names identifying unique sets.

Returns the number of items stored in the set.

Consider the following Set storage:

set_api_example_all_blocks

The example below returns the number of items stored in the "cars" set.
set_api_example_get_key_items_count

The logic produces the following output:

set_api_example_get_key_items_count_2