[英]Referencing operator function '!=' on 'StringProtocol' requires that 'Binding<String>' conform to 'StringProtocol' swiftui
I am new to swiftui and learning it.我是 swiftui 的新手,正在学习它。
I have a situation where I have to Compare Binding with String.我有一种情况,我必须将 Binding 与 String 进行比较。 I can't post a working code because it is very lengthy although I have posted a Statement where I am getting error.
我无法发布工作代码,因为它非常冗长,尽管我已经发布了一个出现错误的声明。
I have to compare Binding with String in order to show and hide few fields based on the comparison.我必须将 Binding 与 String 进行比较,以便根据比较显示和隐藏几个字段。
if $viewModel.users[indexValue].relationshipLabel != "Choose" {
ShowView()
} else {
HideView()
}
Getting error "**Referencing operator function '!=' on 'StringProtocol' requires that 'Binding<String>' conform to 'StringProtocol'**" on line first Statement
Please help me to achieve this.请帮助我实现这一目标。
you only need the "$" dollar sign if you want to use the binding value, it means you want to change the value of it.如果你想使用绑定值,你只需要“$”美元符号,这意味着你想改变它的值。 In your case just use the the variable without the $.
在您的情况下,只需使用不带 $ 的变量。
if viewModel.users[indexValue].relationshipLabel != "Choose" {
ShowView()
} else {
HideView()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.