swift - 是否可以使用 Bond/ReactiveKit 绑定到枚举?迅速
问题描述
我想了解邦德,所以我做了一个测试项目。在这里,我正在使用类巧克力
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 的巧克力,让绑定完成其余的工作。
我必须做出哪些改变?
解决方案
推荐阅读
- python - 如何从字典中的项目连接到字符串
- javascript - 事件源;服务器发送的事件
- c# - 流数据的 CQRS
- c++ - 如何在 Windows 10 IOT 核心上的 Windows UWP 应用程序中运行外部 win32 可执行文件(并能够更新/修改它)?
- java - Java JFrame中用于电子邮件验证的while循环
- numpy - numpy.power() 崩溃了
- kubernetes - Helm 3 中共享 K8s Secrets 的最佳实践?
- ios - ScrollView惯性效果手动,iOS,Swift
- r - 将多个 .csv 文件的第一行复制到新的数据框中
- tus - 不要在 laravel 7 中安装 symfony/console v5.0.5 \ankitpokhrel/tus-php