Insert Before¶
Description¶
This operation inserts a new value before an existing value in a list.
Method¶
[[[Backendless.shared hive:(NSString *)hiveName] listStore:(NSString *)keyName] insertBeforeValueToInsert:(id)valueToInsert anchorValue:(id)anchorValue responseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
Backendless.shared.hive(hiveName: String).listStore(keyName: String).insertBefore(valueToInsert: Any, anchorValue: Any, 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 list. String value. |
valueToInsert |
New value to insert into the list. Can be of any data type. |
anchorValue |
Value which is used as a position anchor. Can be of any data type. |
Return Value¶
The number of values in the list after the insertion operation.
Example¶
The example below inserts the "Apple"
item right before the "Orange"
item in the "fruits"
list.
[[[Backendless.shared hive:@"groceryStore"] listStore:@"fruits"] insertBeforeValueToInsert:@"Apple" anchorValue:@"Orange" responseHandler:^(NSInteger response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").listStore("fruits").insertBefore(valueToInsert: "Apple", anchorValue: "Orange", 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 list. |
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a list. |
item |
New item to insert into the list. |
before item |
Value which is used as a position anchor. |
Returns he number of values in the list after the insertion operation.
Consider the following List storage:
The example below inserts the value "Apple"
before the "Orange"
item in a list identified by the "fruits"
key name:
The list storage will look as shown below after the Codeless logic runs: