所以我是整个Swift的新手,所以请多多包涵..我在swift 2中运行了查询,但是在迁移到swift 3之后,出现了错误
So I am new to swift as a whole so bear with me.. I had the query working in swift 2 but after I migrated to swift 3 I get the error
对成员'request(_:withMethod:parameters:encoding:headers :)'的歧义引用
Ambiguous reference to member 'request(_: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) } })我是
推荐答案我有Alamofire swift3 分支在Xcode 8.0ß6中使用以下代码工作:
I have Alamofire swift3 branch working in Xcode 8.0 ß6 with the following code:
Alamofire.request("\(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) } }请密切注意订单和 .request
您应该只激活一个Alamofire框架。尝试在另一个克隆中重做它,或者在您拥有的克隆中尝试以下操作?
You should have only one Alamofire framework active. Try to redo it in another clone, or maybe try the following in the clone you have?
pod cache clean --all pod install您的 Podfile是什么是否包含在其中?
source 'github/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! target 'NewApp' do pod 'Alamofire', :git => 'github/Alamofire/Alamofire.git', :branch => 'swift3' end更多推荐
迁移到Swift 3后对Alamofire的成员request()问题的含糊不清的引用
发布评论