Hi Catie, I need to understand better. My task is to get a token (which means waiting for a urlSession to return and then calling a second API to do the work. Something like this:
func outerFunction (_ action: innerFunction) {
get Token() { token in
call innerFunction
}
func innerFunction(completion: @escaping (someProtocol)) -> Void {}
How do I do this?
Thanks,
Dan
I think I’m almost there. Here is what I have:
@IBAction func connectTapped(_ sender: Any) {
var aPIManager = APIManager(corporateAccountNumber: ”accountNumber”)
aPIManager.perform { connectRosters in
aPIManager.getConnectRosters { connectRosters in
}
}
}
mutating func perform(_ action: @escaping (_ connectProtocol: ConnectProtocol) -> Void) {
something.performAction { (accessToken, _, error) in
guard error == nil, let token = accessToken else {
alertError()
return
}
if let accessToken = accessToken {
self.token = accessToken
action() // COMPILER THINKS I NEED AN ARGUMENT HERE
}
}
}