2016-11-29 92 views
1

我有Alamofire請求一塊舊的代碼:解析JSON Alamofire 4.水泵進出水

func downloadItemDetails (completed:DownloadComplete) { 
    let url = _itemUrl! 
    Alamofire.request(.GET, url).responseJSON { (request:NSURLRequest?, response:HTTPURLResponse?, result:Result<AnyObject>) -> Void in 
     print(result.value.debugDescription) 
    } 
} 

我應該如何更改代碼,使其與Alamofire 4和斯威夫特3工作?

p.s.我知道更改NSURLRequest - > URLRequestNSHTTPURLResponse - > HTTPURLResponse,我也讀過Alamofire 4.0遷移指南,但它並沒有幫助我。

+0

總是很好的展示研究,並傳達你迄今爲止嘗試過的... –

回答

1

的Alamofire遷移文檔的詳細瞭解之後,我已經通過自己解決問題:

func downloadItemDetails (completed:DownloadComplete) { 

    let url = _itemUrl! 
    Alamofire.request(url, encoding: JSONEncoding.default).responseJSON { response in 
     debugPrint(response) 
    } 
} 

感謝您的關注。 我希望它能幫助別人。