Вы можете сделать это следующим образом
if let chattt = chat["chat"] as? [String:Any] {
//It's available. Execute further tasks
} else {
//It's nil or chat["chat"] type is not dictionary.
}
Вы можете сделать это, используя охрану.
guard let chattt = chat["chat"] as? [String:Any] else {
//Using this, the further code will never execute as implemented force return here
return
}
, если возникнет какая-либо проблема, пожалуйста, дайте мне знать.