我在我的代码中使用了Alamofire和AlamofireObjectMapper。
这是我试图映射的课程:
import ObjectMapper
import ObjectMapper
class ApplicationCollection: Mappable {
var title:String?
var name:String?
var collectionDescription:String?
var collectionId:Int!
var applications:[Application]?
required init?(map: Map) {
}
func mapping(map: Map) {
title <- map["title"]
collectionDescription <- map["description"]
collectionId <- map["id"]
applications <- map["applications"]
}
}
我正在尝试在我的API结构中使用这个类:
import Foundation
import Alamofire
import AlamofireObjectMapper
struct API {
static let URL = "http://mysite.dev/"
enum Path {
case application(Int)
case mainPageCollections
var url:String {
let path:String
switch self {
case .application(let appId):
path = "applicatipn/\(appId)"
case .mainPageCollections:
path = "ApplicationCollections"
}
return API.URL + path
}
}
static func getRuleSetDetail(callback: @escaping (DataResponse<ApplicationCollection>) -> Void){
_ = Alamofire.request(Path.mainPageCollections.url, method: .get, parameters: nil, encoding: URLEncoding.default).responseJSON(completionHandler: callback)
}
}
然后我收到此错误:
无法转换类型'(DataResponse) - &gt;的值Void'到期望的参数类型'(DataResponse) - &gt;无效“
我如何修复此编译错误?
答案 0 :(得分:1)
你应该使用
JmsXA
然后你可以确定基础可映射协议