0
votes

I try to upgrade an objective-c project to Swift. I'm using Azure App Service with a .NET backend to store data from my mobile app (iOS) in the cloud. I just downloaded the quickstart for Swift project from the azure portal and followed the steps in the tutorial to enable offline sync functionality. However inserting an item in the table is not working. I am using the following code to store a new item in the backend

 var table : MSSyncTable?
 ...
 self.table!.insert(item) {
    (result) in
    let syncItem = result.0
    let error = result.1
    if error != nil {
        print("Error: " + error!.localizedDescription)
    }
    ...
}

Stepping through the code at runtime revealed that error is nil so everything should be working fine, but I am not getting a new entry in my table storage.

Does anybody have experience with Azure App Service and Swift and can help me with this?

1

1 Answers

1
votes

Because you are using the sync table, the actual operations to send and receive data from the server are explicit. These are represented by the pushWithCompletion:error: method on the sync context (for sending data up to the cloud), and the pullWithQuery:query:queryId:completion: method on your MSSyncTable.

Note that push automatically occurs when you pull as well.

I would expect the code to look something like:

var table : MSSyncTable?
 ...
 self.table!.insert(item) { result in
    let syncItem = result.0
    let error = result.1
    if error != nil {
        print("Error: " + error!.localizedDescription)
    }
    table!.pushWithCompletion() { error in
      ...
    }
    ...
}