gpt4 book ai didi

ios - fatal error : can't unsafeBitCast between types of different sizes

转载 作者:搜寻专家 更新时间:2023-10-31 19:31:36 25 4
gpt4 key购买 nike

我正在尝试解析 JSON 响应、创建模型实例并填充表格 View 。

这是我的回复:

{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"token": "4L12XJHPWM18",
"name": "Berlin",
"nameShort": "BLN",
"country": "Germany",
"mapLat": 52.5078884,
"mapLng": 13.4392219,
"mapZoom": 13,
"timezone": "CET"
},
...
]
}

这就是我获取和解析它的方式

Alamofire.request(.POST, BGAPIBaseUrlV1, parameters: JSONObject, encoding: .JSON)
.responseJSON { (request: NSURLRequest, response: NSHTTPURLResponse?, object: AnyObject?, error: NSError?) -> Void in

if (object != nil) {
var responseDic = object as [String: AnyObject]
var result: AnyObject? = responseDic["result"]
if let resultArray = result as? Array<Dictionary<String, AnyObject>> {
if (success != nil) {
success!(resultArray)
}
}
}

if (error != nil) {
failure!(error!)
}
}

没问题,直到我尝试遍历我传递给闭包的数组

APIManager.fetchCities({ (cities: Array<Dictionary<String, AnyObject>>) -> Void in
for tmpCity in cities {
var city: CityModel = CityModel(dict: tmpCity) <----------
self.tableViewData.append(city)
}

self.tableView.reloadData()
}, failure: { (error: NSError) -> Void in
println("It didn't work")
})

我收到 EXC_BAD_INSTRUCTION 和以下错误

fatal error: can't unsafeBitCast between types of different sizes

知道为什么吗?

最佳答案

可能您用 String 替换了一些东西! 输入您的“...”,例如如果使用,您将遇到错误:

var str: String! = ""
var data: NSDictionary = [ "myString": str ]

但是

var str: String = ""
var data: NSDictionary = [ "myString": str ]

将正常工作。

关于ios - fatal error : can't unsafeBitCast between types of different sizes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26206125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com