How to update data object in backendless table in swift


I am working with backendless.

After saving data object in backendless table, I can’t update data object.

I have tried several times, but, I have failed.

I have checked following link

But, I don’t understand well

here are sample code

func updateContactAsync(contact:Contact) { let dataStore = Backendless.sharedInstance().data.of(Contact.ofClass()) // update object asynchronously contact.title = “Superman” = “212-555-5555” contact, response: { (result: AnyObject!) -> Void in let updatedContact = result as! Contact print(“Contact has been updated: (updatedContact.objectId)”) }, error: { (fault: Fault!) -> Void in print(“Server reported an error (2): (fault)”) })}

In above code, we receive custom table from parameter.

I am sorry, Would you please explain how to get it?



Here are my sample code

func uploadLoginUser(phone: String, results: @escaping ((_ success: Bool) -> Void)) {

    let userInfo = UserInformation()
    userInfo.userOneId = backendless!.userService.currentUser.objectId! as String
    userInfo.phoneNumber = phone
    userInfo.signIn = "true"
    backendless!.data.of(UserInformation.ofClass())!.save(userInfo, response: { (result: Any?) -> () in
    }) { (fault) in
        ProgressHUD.showError("Error Sending activation code: \(fault!.detail!)")

Hello Andrei,

Firstly, we have our Contact table with the string fields: title and phone and some records in it (screenshot 1).
Here is Contact class description in the Swift project:

class Contact: NSObject {
    var title: String?
    var phone: String?

The code below describes all steps of object update with the comments. The result is on the screenshot 2.

func updateContact() {
 // first of all we're receiing the contact we want to update
 // e.g. it will be the contact with phone number '212-555-6666' (screenshot 1)
 let queryBuilder = DataQueryBuilder()!
 queryBuilder.setWhereClause("phone = '212-555-6666'")
 response: { contactThatWillBeUpdated in
 // and now we can update it with a new phone number '212-555-5555'
 (contactThatWillBeUpdated as! Contact).phone = "212-555-5555"
 // and save the updated contact
 response: { alreadyUpdatedContact in
 print("Updated contact '\((alreadyUpdatedContact as! Contact).title!)' with a new phone number: \((alreadyUpdatedContact as! Contact).phone!)")
 }, error: {fault in
 print("Failed to update contact: \(fault!.message)")
 error: { fault in
 print("Failed to find the contact: \(fault!.message)")

Regards, Olga