所有。 现在我通过观看编码进行转发来研究iOS和swift,alamofire。我使用swift3和alamofire4,但他们教它alamofire3和swift2,所以我很困惑。你能帮我解决问题吗?
有类似的错误“无法将类型'NSMutableURLRequest'的值转换为预期的参数类型'SessionManager'”
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if let Purl = NSURL(string: self.projectUrl){
var mutableUrlRequest = NSMutableURLRequest(url: Purl as URL)
mutableUrlRequest.setValue("JWT \(self.tokenUse)", forHTTPHeaderField: "Authorization")
mutableUrlRequest.httpMethod = "GET"
var getProjects = Alamofire.SessionManager.request(mutableUrlRequest)
.responseJSON{ response in
print(response.request)
print(response.response)
print(response.data)
print(response.result)
}
}
}
答案 0 :(得分:0)
Alamofire很可能期望使用原生的Swift 3语法:
if let Purl = URL(string: self.projectUrl) {
var mutableUrlRequest = URLRequest(url: Purl)
URLRequest
可自由声明为var
iable。