I new in swift and I wrote simple api connector to get info from server, but I do not know how to get my data from server and use it in app
var account: DriverAccount = DriverAccount()
ApiConnectController.instance().makeAPICall(url: driverAuthUrlEndpoint,
params:paramsDictionary,
withAutorization: false,
method: .POST,
success: { (data, response, error, json) in
self.account = try! DriverAccount(json: json!) // Error Closure cannot implicitly capture a mutating self parameter
print("OK")
},
failure: { (data, response, error, json) in
print("NOT")
})
How to get data into self.account?
class DriverAccount {
var callSign: String?
var dispPhone: String?
var isLoggedin:Bool
init() {
self.callSign = ""
self.dispPhone = ""
self.isLoggedin = false
}
init(isLoggedIn logedIn: Bool, withCallSign callsign: String, andDispPhone dispPhone: String) {
self.callSign = callsign
self.dispPhone = dispPhone
self.isLoggedin = logedIn
}
}