Swift

From Bitpost wiki
Revision as of 22:52, 25 July 2022 by M (talk | contribs) (Created page with "== Concepts == * @Binding: allows one "source of truth" with many references called bindings * @StateObject: an object owned and mutated by its parent class * Codable: a desig...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Concepts

  • @Binding: allows one "source of truth" with many references called bindings
  • @StateObject: an object owned and mutated by its parent class
  • Codable: a designation that an object can be en/decoded
  • Identifiable: a designation that an object uses predictable identification (eg via an ID)
  • Custom modifiers allow you to put all your modifiers (eg .font(.headline)) into one reusable set.

Modifiers vs Custom View

Tip: Often folks wonder when it’s better to add a custom view modifier versus just adding a new method to View, and really it comes down to one main reason: custom view modifiers can have their own stored properties, whereas extensions to View cannot.

Lessons learned

  • Lists should have NavigationView parents
  • To avoid the FAT ASSED UGLY NavigationView header in the top navigation view (where you do not WANT it, doh), you have to set this on the EMBEDDED view (not NavigationView):
.navigationBarHidden(true0
.navigationBarTitle("") // don't skip this or it won't work, DOH

SwiftUI vs UIKit

UIKit is OLD and BIG. You'll still need it to get to some Apple services until SwiftUI is fully fleshed out. For my JSON API driven apps, I WILL AVOID IT LIKE THE PLAGUE, and hold out for SwiftUI expansion.