在迁移到swift 3之后,对Alamofire的成员request()问题进行了歧义性的引用

rya*_*app 7 swift alamofire swift3 xcode8

所以我对整个swift很新,所以请耐心等待..我的查询在swift 2中工作但是在我迁移到swift 3之后我得到了错误

对成员请求的不明确引用(_:withMethod:parameters:encoding:headers :)'

下面是它出现的代码:

Alamofire.request(.GET, serverRequest).validate().responseJSON( { response in
        switch response.result{
        case .Success:
            if let JSON = response.result.value {
                let final = JSON[wantedClass] as! String//forces output to string
                self.failure("You asked what your " + wantedClass + " is, it is:", message: final)
            }
        case .Failure(let error):
            print(error)
        }
})
Run Code Online (Sandbox Code Playgroud)

我不知道是什么问题.

pop*_*cnt 5

我让Alamofire swift3分支在Xcode8.0ß6中工作,代码如下:

Alamofire.request("https://\(ip)/api/version", withMethod: .get, 
    parameters: nil, encoding: .json, headers: headers)
            .validate()
            .responseJSON { response in
                //debugPrint(response)
                switch response.result {
                case .success:
                    if let JSON = response.result.value {
                        let version = Mapper<Version>().map(JSON)
                        print("Version \(version?.server!)")
                    }
                case .failure(let error):
                    print (error)
                }
            }
Run Code Online (Sandbox Code Playgroud)

密切关注你的参数的顺序和类型 .request

您应该只有一个Alamofire框架处于活动状态.尝试在另一个克隆中重做它,或者在您拥有的克隆中尝试以下内容?

pod cache clean --all
pod install
Run Code Online (Sandbox Code Playgroud)

Podfile有什么?

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'NewApp' do
    pod 'Alamofire', 
        :git => 'https://github.com/Alamofire/Alamofire.git',
        :branch => 'swift3'
end
Run Code Online (Sandbox Code Playgroud)