Lov*_*wat 5 ios swift alamofire swift3
我在使用Swift 3.0时使用了Alamofire 4.0,但是遇到了以下代码的问题
类型'方法'(又名'OpaquePointer')没有成员'GET'
类型'方法'(又名'OpaquePointer')没有成员'PUT'
类型'方法'(又名'OpaquePointer')没有成员'POST'
类型'方法'(又名'OpaquePointer')没有成员'PATCH'
类型'方法'(又名'OpaquePointer')没有成员'DELETE'
枚举定义:
enum Method {
case get
case put
case post
case patch
case delete
func toAFMethod() -> Alamofire.Method {
switch self {
case .get:
return Alamofire.Method.GET
case .put:
return Alamofire.Method.PUT
case .post:
return Alamofire.Method.POST
case .patch:
return Alamofire.Method.PATCH
case .delete:
return Alamofire.Method.DELETE
}
}
}
Run Code Online (Sandbox Code Playgroud)
Ash*_*kad 12
基于Swift 3和Alamofire 4.0,API发生了重大变化:
import Alamofire
enum Method {
case get
case put
case post
case patch
case delete
func toAFMethod() -> Alamofire.HTTPMethod {
switch self {
case .get:
return Alamofire.HTTPMethod.get
case .put:
return Alamofire.HTTPMethod.put
case .post:
return Alamofire.HTTPMethod.post
case .patch:
return Alamofire.HTTPMethod.patch
case .delete:
return Alamofire.HTTPMethod.delete
}
}
}
Run Code Online (Sandbox Code Playgroud)
希望这会帮助你.
| 归档时间: |
|
| 查看次数: |
2838 次 |
| 最近记录: |