如何在 SwiftUI@State
的语句中使用关联的枚举作为变量?if
struct ProfileView: View {
@State private var choice = Choice.simple
private enum Choice {
case simple
case associated(Int)
}
var body: some View {
if choice == .simple {
Text("Simple")
}
}
}
编译器报告此错误:
协议“Equatable”要求“ProfileView.Choice”符合“Equatable”