How can I run an action when a state changes?

后端 未结 7 2199
醉话见心
醉话见心 2020-12-05 22:25
enum SectionType: String, CaseIterable {
    case top = \"Top\"
    case best = \"Best\"
}

struct ContentView : View {
    @State private var selection: Int = 0

           


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 23:21

    You can use Binding

    let textBinding = Binding(
        get: { /* get */ },
        set: { /* set $0 */ }
    )
    

提交回复
热议问题