Post

Replies

Boosts

Views

Activity

Reply to Initialization order of SwiftUI Application + @UIApplicationDelegateAdaptor
Don't overthink the architecture. You should not be using or depending on didSet. The documentation states then once an application delegate also conforms to the ObservableObject type it is automatically available to the entire SwiftUI Application because it places it into the Environment via the EnvironmentObject on your behalf. So move away from the swift didSet/willSet paradigm for property observations and move toward combine or publishers in the form of making the properties of interest into annotated @Published type. Then anywhere in your swiftUI code that needs access to some kind of data from the app delegate will automatically have it via the following pattern. @EnvironmentObject private var appDelegate: MyAppDelegate Read here: https://developer.apple.com/documentation/swiftui/uiapplicationdelegateadaptor
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’22
Reply to Had this error for days now and I can't fix it
The following works without issue. struct ContentView: View {     enum ModelCategory: String, CaseIterable, Identifiable {         case one, two, three, four, five, six         var id: String {             self.rawValue         }     }     var body: some View {         VStack {             ForEach(ModelCategory.allCases, id: \.self) { value in                 Text(value.id)             }         }     } } But because you have introduced a member variable that is not initialized this is the error being raised. If you have a preview snippet, pass the showBrowse param into the ModelsByCategoryGrid(showBrowse: Binding.constant(false)) or give the showBrowse a default value.     @Binding var showBrowse: Bool
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’22