Updating Data Items

Updating Data Items

The Backend Services iOS SDK allows you to update single or multiple data items in a single method call. It supports automatic updating of items.

Updating a Single Item

It is important to know that we currently do not track the properties that have been changed. Every time you want to make an update to a single item, you need to send the whole object to the server. The following code will update the text field of the testActivity object.

testActivity.text = @"Another great day at the beach.";
[dataStore update:testActivity block:^(BOOL success, NSError *error) {
    // success will indicate if the update was successful
}];

Updating Multiple Items

To make multiple update, you have to create an item and set its properties with the new values. Then pass this object to the update method and set the predicate, which will filter the items. The following example will update all items with text "Some text" and set it to "Another great day at the beach.".

testActivity.text = @"Another great day at the beach.";
[dataStore update:testActivity withPredicate:[NSPredicate predicateWithFormat:@"Text == 'Some text'"] block:^(BOOL success, NSError *error){
    // success will indicate if the update was successful
}];

Be careful when updating fields marked as unique (IsUnique) by filter as it may match multiple items. In this case, Telerik Platform updates the first matching item if the update value does not duplicate an existing item, after which it stops executing the request and returns an error. The rest of the matching items are not updated.

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.