I have an extension on a class called APIManager:
import Alamofire
import Foundation
// MARK: - Logout
extension APIManager {
public func performLogout() {
let request = defaultManager.request(APIManager.Router.Logout.URLRequest)
request.response( // ERROR ON THIS LINE AS NOTED BELOW
queue: APIManager.responseQueue,
responseSerializer: Request.stringResponseSerializer(),
completionHandler: { [weak self] (response) in
guard let strongSelf = self else { return }
}
)
}
}
When the extension is included underneath the APIManager class in the SAME FILE, there is no issue whatsoever.
However, when I take the extension and move it into a NEW FILE, I receive this error:
Cannot call value of non-function type 'NSHTTPURLResponse?'
It's obvious that when the extension is placed in another file, the compiler is confusing the method above as defined Alamofire/ResponseSerialization.swift with the 'response' property in Alamofire/Request.swift of the Alamofire Request class
The APIManager class is below:
public final class APIManager {
// MARK: - Singleton shared instance
static let sharedInstance = APIManager()
let defaultManager: Alamofire.Manager = {
let serverTrustPolicies: [String: ServerTrustPolicy] = [
"TBD1": .PinCertificates(
certificates: ServerTrustPolicy.certificatesInBundle(),
validateCertificateChain: true,
validateHost: true
),
"TBD2": .DisableEvaluation
]
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.HTTPAdditionalHeaders = Alamofire.Manager.defaultHTTPHeaders
return Alamofire.Manager(
configuration: configuration,
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies)
)
}()
}
There is a similar question here but it's not quite the same:
Cannot call value of non-function type 'NSHTTPURLResponse?' Alamofire ObjectMapper
If this is, as you say, working fine in the other file a couple of suggestions come to mind.
Let me know if your issue still persists and I will investigate further.