Created array of dictionary having buttons.
-创建了 UITableviewcell.xib 和 .swift -创建了IB 链式IB -链接的数据源和委托(delegate) 需要进一步帮助来读取我的 plist 数据并将其显示到 tableViewCell
最佳答案
使用Decodable
,非常简单
struct Section : Decodable {
let title, icon : String
}
如果文件在 bundle 中,则将其读取为数据
并对其进行解码
let url = Bundle.main.url(forResource: "sections", withExtension: "plist")!
do {
let data = try Data(contentsOf: url)
let result = try PropertyListDecoder().decode([Section].self, from: data)
} catch { print(error) }
结果
将包含Section
项的数组
关于arrays - 我想将具有属性(btnImage + btnTitle)的字典数组从Plist读取到TableViewCell中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54106230/