迁移到Swift 3后对Alamofire的成员request()问题的含糊不清的引用

编程入门 行业动态 更新时间:2024-10-23 17:28:50
本文介绍了迁移到Swift 3后对Alamofire的成员request()问题的含糊不清的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我是整个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()问题的含糊不清的引用

本文发布于:2023-11-26 17:23:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634492.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不清   成员   Swift   Alamofire   request

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!