I need to do an API call and wait until I get response back before returning the value.
This however won't compile:
func doKYCCheckForCustomer(kycRecord: KYCRecord) -> Bool {
ApiManager.sharedInstance.postUserToArtemis(kycRecord) {(response, error) in
DispatchQueue.main.async {
if error != nil {
// Error on doing kyc check
print(0)
return false
} else {
// No error on doing kyc check
print(1)
return true
}
}
}
}
The error Xcode is telling me is:
Unexpected non-void return value in void function
I don't think this is a void function. It returns a boolean so why is Xcode complaining about this?
I'm looping over a bunch of records to do this API call for so I need to make sure that the previous one is finished before executed a new call.