Ios Can';t使用ObjectMapper Swift 4.1序列化
尝试使用Alamofire和AlamoFireObject Mapper时,我收到一个错误 我的函数调用apiIos Can';t使用ObjectMapper Swift 4.1序列化,ios,swift,realm,Ios,Swift,Realm,尝试使用Alamofire和AlamoFireObject Mapper时,我收到一个错误 我的函数调用api static func getUberIntegration(completion: @escaping ([Integrations]?) -> ()) { let url = "\(Url.baseURL())/integrations" let headers = Headers.authorization() Alamof
static func getUberIntegration(completion: @escaping ([Integrations]?) -> ()) {
let url = "\(Url.baseURL())/integrations"
let headers = Headers.authorization()
Alamofire.request(url, headers: headers).responseArray { (response: DataResponse<[Integrations]>) in
let integration = response.result.value
print(integration!)
completion(integration)
}
}
谁能解释为什么会发生这个问题?当我在调试中打印时,状态代码是返回代码200,但无法读取json数据
我得到这个错误
错误域=com.alamofileobjectmapper.Error代码=2“ObjectMapper
未能序列化响应。“
您是object或object?object only的api响应数组@a.masriOk,请尝试将此
DataResponse
替换为DataResponse
class Integrations: Object, Mappable {
@objc dynamic var id: Int32 = 0
@objc dynamic var type: String = ""
@objc dynamic var active: Bool = false
override static func primaryKey() -> String? {
return "id"
}
required convenience init?(map: Map) {
self.init()
}
func mapping(map: Map) {
id <- map["id"]
type <- map["type"]
active <- map["active"]
}
}
{
"id": 120,
"type": "Integration",
"active": true
}