Skip to content

Length

Description

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

Method

[[[Backendless.shared hive:(NSString *)hiveName] mapStore:(NSString *)keyName] lengthWithResponseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).mapStore(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 map. String value.

Return Value

The total number of items stored in the specified map.

Example

The example below returns the total number of items stored in the "fruits" map.

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

where:

Argument                Description
"groceryStore" Name of a hive where the operation is performed.
"fruits" Key name identifying a map.

Codeless Reference

map_api_get_keys_count

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a map.

Returns the total number of items stored in the specified map.

Consider the following Map storage:
map_apI_example_map_store

The example below counts the number of values in the "fruits" map:

map_api_example_get_keys_couint

The output will look as shown below after the Codeless logic runs.
sorted_set_api_example_get_key_values_count._2