Set Value By Key Name¶
Description¶
This operation replaces the value linked to a key in the map.
Method¶
[[[Backendless.shared hive:(NSString *)hiveName] mapStore:(NSString *)keyName] setWithKey:(NSString *)key value:(id)value responseHandler:^(BOOL)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).mapStore(keyName: String).set(key: String, value: Any, responseHandler: ((Bool) -> 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. |
key |
Name of the key whose value is replaced. String value. |
value |
New value for the key. Can be of any data type. |
Return Value¶
If the specified key does not exist, then this operation adds a new key-value pair to the map and returns true
. Otherwise, returns false
if a value associated with the specified key is replaced by a new value.
Example¶
The example below sets a new value 1.29
for the "Oranges"
key. This invocation returns false
indicating that the current value has been replaced.
[[[Backendless.shared hive:@"groceryStore"] mapStore:@"fruits"] setWithKey:@"Oranges" value:@1.29 responseHandler:^(BOOL response) {
// handle response
} errorHandler:^(Fault * fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").mapStore("fruits").set(key: "Oranges", value: 1.29, 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
¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a map. |
values(object) |
An object containing a new value for a key. |
Returns false
if an existing key-value pair is updated. Returns true
if a new key-value pair is added to the map.
Consider the following Map storage:
The example below sets a new value 1.29
for the "Oranges"
key. If the specified key does not exist, then a new key-value pair is added to the map.
The map will look as shown below after the Codeless logic runs: