Xcode DataAbstract IOS 14 Async Example Needed with network error messages

In the past year we have built an Xcode IOS SwiftUI app using DataAbstract for communication with our backend Delphi DataAbstract custom servers.

Have had the application in the field since May, 2020 at multiple customer sites. And everything has worked really well. I personally love SwiftUI. Our program is really big since it does full work order process with line detail, lookups for data, time, and dates, equipment entry, equipment photos, etc.

But. Now we are beginning to look at doing the comms in the background with timers. Possibly with the new Combine provided by Apple which we have tested with standard http calls. We are trying to build a way to sync timesheet clock in and out entries seamless without the technicians have to worry about the sync operations. Our Ipad app works disconnected using CoreData on the Ipad for all the work entry. Communications only occurs when the cellular or wifi is available. We disable the sync buttons if communications with the servers is not available.

Prior to any data connection to the servers, we check the network using a quick DA Async call to determine if we can truly start our bigger data sync operations.

On the bigger transfers, we have not been able ( stupidity certainly on our part ) to build functions for the data table calls using the Async calls that return the DataTable and Error messages.

We have several hundred tables on the servers that provide the entire accounting spectrum from general ledger to order entry. So we want to build something that will endure the next few years without problems.

Our question this morning - Do you have a good prototype function example of how to perform the Async calls that return the DataTable and network error messages in case of a bad url or communication failure .

We want something that we can reuse over and over and over. From the DataAdapter to the Get of the DataTables.

Below is what we use every time before we start our non-Async table calls. It is a simple call to pull the States table which is tiny ( 50 records ). Very quick and gives us an idea if comms are available. If it fails, we do not proceed to the actual table transfers. We do not use the Async on those transfers. That is what we are wanting to do.

  func detectConnection() {
         self.canConnect = false
         self.isInternet = NetStatus.shared.isConnected
         if ( self.isInternet == true ) && ( appSettings.gHost_Address != "" ) {
             DataAbstractAccess.sharedInstance.rda.beginGetDataTable( "States" ) { dataTable in
                 print( "Row Count: \(dataTable.rowCount)")
                 if ( dataTable.rowCount > 0 ) {
                     self.canConnect = true

Below is what we use for most table transfers. The one below pulls the Terms file with a where statement.

func Terms_DA_SelectQueryWithWhere( _ xField: String, _ xFieldValue : String  ) -> DADataTable {
    print( "Get Table Terms - Field: \(xField) - Value: \(xFieldValue) " )
    let predicateFieldValue = xFieldValue             // Example: "ATR036C"
    let predicateArray      = [ predicateFieldValue ]
    let predicateStatement  = "\(xField) like '%\(xFieldValue)%' "
    let predicate = NSPredicate(format: predicateStatement, argumentArray: predicateArray )
    let whereClause = DADynamicWhereClause(predicate: predicate)
    let table = DataAbstractAccess.sharedInstance.rda.getDataTable( "Terms", select: nil, where: whereClause )
    return table