SwiftUI @State vs Binding

前端 未结 6 1596
野的像风
野的像风 2021-02-04 12:43

I am learning iOS Programming with Swift and SwiftUI. I know very little and I am very confuse about the difference between a @State and a Binding<*>

6条回答
  •  独厮守ぢ
    2021-02-04 13:48

    State simple properties like string, integers, and Booleans Belong to a single view - mark as private

    Binding complex properties like custom type Sharing data in many views. Required for reference types

    EnvironmentObject properties created elsewhere such as shared data App crashes if it is missing.

提交回复
热议问题