【发布时间】:2023-04-02 15:35:01
【问题描述】:
我更新了swift 3,发现很多错误。这是其中之一:
“任何?”类型的值没有成员“对象”
这是我的代码:
jsonmanager.post( "http://myapi.com",
parameters: nil,
success: { (operation: AFHTTPRequestOperation?,responseObject: Any?) in
if(((responseObject? as AnyObject).object(forKey: "meta") as AnyObject).object(forKey: "status")?.intValue == 200 && responseObject?.object(forKey: "total_data")?.intValue > 0){
let aa: Any? = (responseObject? as AnyObject).object(forKey: "response")
self.data = (aa as AnyObject).mutableCopy()
}
新错误更新:
可选链无效,表达式已经产生'Any?'
和
不能调用非函数类型'Any?!'的值
在以前的版本 7.3.1 swift 2 中运行良好。
这是 json 响应:
{
"meta":{"status":200,"msg":"OK"},
"response":[""],
"total_data":0
}
【问题讨论】:
-
请向我们展示您的 json 响应?
-
查看更新的问题@NiravD
-
我已经告诉过您向我们展示您的 json 响应,以便我们可以在此基础上创建字典。
-
jsonmanager是什么类型? -
@kabiroberai AFHTTPRequestOperationManager