gpt4 book ai didi

ios - 你如何找出一个对象的类型

转载 作者:行者123 更新时间:2023-11-28 07:56:20 25 4
gpt4 key购买 nike

我怎么知道输入的值是图像,字符串,音频还是视频 如果有人有想法,请 swift 帮助我。

在排序中,我想知道对象的类型。

 cell = Chat_CollectionView.dequeueReusableCell(withReuseIdentifier:
Identifier, for: indexPath)as! SingleChat_Cell
let data = sender.object(at: indexPath.row)

现在我想知道数据的数据类型

最佳答案

 cell = Chat_CollectionView.dequeueReusableCell(withReuseIdentifier:
Identifier, for: indexPath)as! SingleChat_Cell

let data = sender.object(at: indexPath.row)
if (data as? String) != nil { // check if data is String type
// your code here
}

if (data as? UIImage) != nil { // check if data is UIImage type
// your code here

}

if (data as? Data) != nil { // check if data is Data type for audio or video
// your code here

}

关于ios - 你如何找出一个对象的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47939507/

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