1

I've recently started looking into iOS development and I'm attempting to pick up the SwiftUI framework, all is going good, but I've hit a snag when I came across these @State or @Binding words. I'm still having a difficult time understanding which one should be used instead of the other.

Can someone please provide a summary about these and explain what they are used for exactly? Thank you.

wasdesc
  • 27
  • 2
  • 1
    Lot of good answers in that question. Also a list off all the wrappers and what they do. – burnsi Aug 01 '22 at 22:59
  • @burnsi Thank you for that, that does help. One of the answers outlined mentioned: "State holds value, the 'source of truth' while Binding pass value, use as pipeline". So if I wanted to get a simple string from a network call when my app loads and pass that onto my View, would I use State or Binding? Apologies if this question is incorrect to ask.. still learning about these things – wasdesc Aug 02 '22 at 01:49
  • Use `@State` in the view that loads the value and either `@Binding` if the subview manipulates it or a simple var if not. But all of this is answered in the linked question. Also there are a lot of good tutorials about this out there. – burnsi Aug 02 '22 at 08:44

0 Answers0