Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用Alamofire和ObjectMapper,我的模型类就是这样 class Category: Object, Mappable {dynamic var id: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<Category>()override static fun 我正在使用Alamofire和ObjectMapper,我的模型类就是这样

class category: Object,Mappable {dynamic var ID: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<category>()overrIDe static func primaryKey() -> String? {    return "ID"}required convenIEnce init?(_ map: Map) {    self.init()}func mapPing(map: Map) {    ID <- map["ID"]    name <- map["name"]    thumbnail <- map["thumbnail"]    children <- map["children"]}

}

而我正在使用这样的Alamofire

Alamofire.request(.GET,url).responseArray { (response: Response<[category],NSError>) in        let categorIEs = response.result.value        if let categorIEs = categorIEs {            for category in categorIEs {                print(category.ID)                print(category.name)            }        }    }

ID永远为零,我不知道为什么?

解决方法 我通过在模型类中的映射函数中添加转换来修复它

ID <- (map["ID"],transformOf<Int,String>(fromJsON: { Int([+++]!) },toJsON: { [+++].map { String([+++]) } }))

感谢@BobWakefIEld

总结

以上是内存溢出为你收集整理的swift – 使用Alamofire和Objectmapper,整数值始终为零全部内容,希望文章能够帮你解决swift – 使用Alamofire和Objectmapper,整数值始终为零所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用Alamofire和ObjectMapper,我的模型类就是这样 class Category: Object, Mappable {dynamic var id: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<Category>()override static fun 我正在使用Alamofire和ObjectMapper,我的模型类就是这样

class category: Object,Mappable {dynamic var ID: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<category>()overrIDe static func primaryKey() -> String? {    return "ID"}required convenIEnce init?(_ map: Map) {    self.init()}func mapPing(map: Map) {    ID <- map["ID"]    name <- map["name"]    thumbnail <- map["thumbnail"]    children <- map["children"]}

}

而我正在使用这样的Alamofire

Alamofire.request(.GET,url).responseArray { (response: Response<[category],NSError>) in        let categorIEs = response.result.value        if let categorIEs = categorIEs {            for category in categorIEs {                print(category.ID)                print(category.name)            }        }    }

ID永远为零,我不知道为什么?

解决方法 我通过在模型类中的映射函数中添加转换来修复它

ID <- (map["ID"],transformOf<Int,String>(fromJsON: { Int(!) },toJsON: { [+++].map { String([+++]) } }))

感谢@BobWakefIEld

总结

以上是内存溢出为你收集整理的swift – 使用Alamofire和Objectmapper,整数值始终为零全部内容,希望文章能够帮你解决swift – 使用Alamofire和Objectmapper,整数值始终为零所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用Alamofire和ObjectMapper,我的模型类就是这样 class Category: Object, Mappable {dynamic var id: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<Category>()override static fun 我正在使用Alamofire和ObjectMapper,我的模型类就是这样

class category: Object,Mappable {dynamic var ID: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<category>()overrIDe static func primaryKey() -> String? {    return "ID"}required convenIEnce init?(_ map: Map) {    self.init()}func mapPing(map: Map) {    ID <- map["ID"]    name <- map["name"]    thumbnail <- map["thumbnail"]    children <- map["children"]}

}

而我正在使用这样的Alamofire

Alamofire.request(.GET,url).responseArray { (response: Response<[category],NSError>) in        let categorIEs = response.result.value        if let categorIEs = categorIEs {            for category in categorIEs {                print(category.ID)                print(category.name)            }        }    }

ID永远为零,我不知道为什么?

解决方法 我通过在模型类中的映射函数中添加转换来修复它

ID <- (map["ID"],transformOf<Int,String>(fromJsON: { Int(!) },toJsON: { .map { String([+++]) } }))

感谢@BobWakefIEld

总结

以上是内存溢出为你收集整理的swift – 使用Alamofire和Objectmapper,整数值始终为零全部内容,希望文章能够帮你解决swift – 使用Alamofire和Objectmapper,整数值始终为零所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
swift – 使用Alamofire和Objectmapper,整数值始终为零_app_内存溢出

swift – 使用Alamofire和Objectmapper,整数值始终为零

swift – 使用Alamofire和Objectmapper,整数值始终为零,第1张

概述我正在使用Alamofire和ObjectMapper,我的模型类就是这样 class Category: Object, Mappable {dynamic var id: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<Category>()override static fun 我正在使用Alamofire和ObjectMapper,我的模型类就是这样

class category: Object,Mappable {dynamic var ID: Int = 0dynamic var name = ""dynamic var thumbnail = ""var children = List<category>()overrIDe static func primaryKey() -> String? {    return "ID"}required convenIEnce init?(_ map: Map) {    self.init()}func mapPing(map: Map) {    ID <- map["ID"]    name <- map["name"]    thumbnail <- map["thumbnail"]    children <- map["children"]}

}

而我正在使用这样的Alamofire

Alamofire.request(.GET,url).responseArray { (response: Response<[category],NSError>) in        let categorIEs = response.result.value        if let categorIEs = categorIEs {            for category in categorIEs {                print(category.ID)                print(category.name)            }        }    }

ID永远为零,我不知道为什么?

解决方法 我通过在模型类中的映射函数中添加转换来修复它

ID <- (map["ID"],transformOf<Int,String>(fromJsON: { Int(!) },toJsON: { .map { String() } }))

感谢@BobWakefIEld

总结

以上是内存溢出为你收集整理的swift – 使用Alamofire和Objectmapper,整数值始终为零全部内容,希望文章能够帮你解决swift – 使用Alamofire和Objectmapper,整数值始终为零所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1001598.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存