Skip to content

Latest commit

 

History

History
83 lines (68 loc) · 1.79 KB

File metadata and controls

83 lines (68 loc) · 1.79 KB

QMobileAPI

swift carthage

Network layer to communicate with 4D server rest API. Part of iOS SDK

Build

Using Xcode project

To download dependencies use carthage checkout

then open workspace with Xcode and compile

Using swift package manager

You can open Package.swift with Xcode and compile or launch standards command line for swift, see build.sh

How to

Initialize

Create your endpoint to make request

let url = URL(string: "http://your4dserverURL")!
let api = APIManager(url: url)

Make request

Server info

api.loadStatus { result in
   switch result {
      case .success(let info):
        print("\(status.ok)")
      case .failure(let error):
        print("\(error)")
   }
}
api.loadInfo { result in
  switch result {
     case .success(let info):
       ...
     case .failure(let error):
       print("\(error)")
  }
}

Table/Catalog

api.loadTables { result in
  switch result {
     case .success(let tables):
      for table in tables {
       ...
      }
     case .failure(let error):
       print("\(error)")
  }
}
api.loadTable(name: "ATable") { result in
  switch result {
     case .success(let table):
       ...
     case .failure(let error):
       print("\(error)")
  }
}
api.loadCatalog { result in
  switch result {
     case .success(let catalogs):
       for catalog in catalogs {
        ...
       }
     case .failure(let error):
       print("\(error)")
  }
}