2017-02-17 91 views
0

我已经搜索了许多类似于我想要的问题,但找不到答案。我的语法与其他答案不同,无法弄清楚。我已经转移到斯威夫特3和更新后,我的Alamofire cocopod到4.3,我得到的错误:Alamofire要求得到错误'额外的参数在呼叫'

Extra Argument in call

这是我得到它的代码:

request = Alamofire.request(.GET, post.imageURL!).validate(contentType: ["image/*"]).response(completionHandler: { (request, response, data, err) in 

有人可以告诉我新代码呢?

+0

你看过[Alamofire 4.0迁移指南](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md)吗?见例如_Response Serializers_部分;引用:_“响应API返回了4个参数,而不是封装响应类型。”_。正如在[类似的问答](http://stackoverflow.com/questions/41447819/)(其中之一)上面的特定问题是您对旧的应用(完成处理程序)的用法:现在它封装了一个参数(不是4)。 – dfri

回答

0

答案是这到底:

request = Alamofire.request(post.profileImage!).validate(contentType: ["image/*"]) 
        .response { response in 

         if response.error == nil { 
         let image = UIImage(data: response.data!)! 

我希望这可以帮助别人。 :)