Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

swift - 'Method' is ambiguous for type lookup in this context, Error in Alamofire

I am using Alamofire for network handling in swift and run into one weird error. It seems like we can't pass Method enum as parameter.
[Error is on Method parameter]

enter image description here

private func apiRequest(method: Method, url: String, apiData: [String : AnyObject], completion:(finished: Bool, response: AnyObject?) ->Void) {

    Alamofire.request(method, url, parameters: apiData).responseJSON{ response in
        if let JSON = response.result.value {
            completion(finished: true, response: JSON)
        } else {
            completion(finished: false, response:nil)
        }
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to specify the module from which to lookup object type. Call Alamofire.Method


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...