Search code examples
iosswiftafnetworkingswift4type-alias

Swift 4 AFNetworking typealias conversion error


I'm migrating to Swift 4 and I have the following typealias:

typealias AFDataSuccess = (task: URLSessionDataTask, responseObject: Any?)

but I'm having trouble converting it as shown in the attached image:

enter image description here


Solution

  • You have to use like this :

    manager.post(route.url, parameters: params, progress: nil, success: { (task: URLSessionDataTask, response: Any?) in
        print(response)
    }) { (task: URLSessionDataTask, error: Error) in
       print(error.localizedDescription)
    }