LoginSignup
21
21

More than 5 years have passed since last update.

Swift3へ移行する際のAlamofire周りの修正箇所

Posted at

基本的には以下の移行ガイドに名前空間の変更などがまとまっています。
https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md

名前空間の変更

  • Manager => SessionManager
  • Request.TaskDelegate => TaskDelegate
  • Request.DataTaskDelegate => DataTaskDelegate
  • Request.DownloadTaskDelegate => DownloadTaskDelegate
  • Request.UploadTaskDelegate => UploadTaskDelegate

移行ガイドには書いていませんが、Alamofire.Methodも変わっています。

  • Alamofire.Method => Alamofire.HTTPMethod

また、HTTPMethodはenumのため、.GET.POST.get.postという小文字表記に変更になっています。
Xcodeの自動変換ではこのあたりは対応されません・・。

URLStringConvertible

URLStringConvertibleURLConvertibleに改名され、中身も変わっています。

public protocol URLStringConvertible {
    var URLString: String { get }
}

public protocol URLConvertible {
    func asURL() throws -> URL
}

よって、requestuploadに使われるURLRequestが順守しているプロトコルもURLStringConvertibleからURLConvertibleになりました。
このあたりも自クラスにて再定義していることがあれば対応が必要です。

21
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
21