gpt4 book ai didi

ios - 将 UITextView 绑定(bind)到 MutableProperty

转载 作者:行者123 更新时间:2023-11-29 00:30:02 27 4
gpt4 key购买 nike

如何将 UITextView 的文本属性绑定(bind)到 MutableProperty,例如

let property = MutableProperty<String>("")
commentTextView.text <~ property

这只是给了我错误

Binary operator '<~' cannot be applied to operands of type 'String!' and 'MutableProperty<String>'

但我不明白为什么。

是否有文档说明绑定(bind)如何在 ReactiveSwift 中工作?

我检查了几个潜在的来源,例如 GitHub project 上的非常简短的文档。和 reactivecocoa.io ,但读完之后我感觉 ReactiveSwift 无法做到这一点。

我还读过另一本similar question ,但接受的答案似乎不适用于这种情况或者是错误的。

最佳答案

这是一个句法上的误解,我从稀疏的 ReactiveSwift 文档中看得不是很清楚。必须在两者之间添加一个 .reactive:

let property = MutableProperty<String>("")
commentTextView.reactive.text <~ property

关于ios - 将 UITextView 绑定(bind)到 MutableProperty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42141948/

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