我想了解邦德,所以我做了一个测试项目。在这里,我正在使用类巧克力
class Chocolate {
var brandname: String = ""
var type: ChocolateType = .crunchy
}
和一个带有 rawValues 的枚举 ChocolateType
enum ChocolateType: String {
case crunchy = "crunchy"
case nougat = "nougat"
case dark = "dark"
case white = "white"
case nuts = "nuts"
}
有什么方法可以将标签或另一个 UIObject 绑定到 ChocolateType,以便使用 text = label.text 进行更新?
有利的是,我想给 ViewController 只是来自 ViewModel 的巧克力,让绑定完成其余的工作。
我必须做出哪些改变?