Post

Replies

Boosts

Views

Activity

Reply to Xcode 14: Publishing changes from within view updates
This code was producing the same warning: struct AreaMap: View {   @Binding var region: MKCoordinateRegion   var body: some View {     Map(coordinateRegion: $region)   } } Where region was passed in the initializer of AreaMap from its parent view. This resolved the issue: struct AreaMap: View {   @Binding var region: MKCoordinateRegion   var body: some View {     let binding = Binding(       get: { self.region },       set: { newValue in         DispatchQueue.main.async {           self.region = newValue         }       }     )     return Map(coordinateRegion: binding)   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to Xcode 14: Publishing changes from within view updates
This code was producing the same warning: struct AreaMap: View {   @Binding var region: MKCoordinateRegion   var body: some View {     Map(coordinateRegion: $region)   } } Where region was passed in the initializer of AreaMap from its parent view. This resolved the issue: struct AreaMap: View {   @Binding var region: MKCoordinateRegion   var body: some View {     let binding = Binding(       get: { self.region },       set: { newValue in         DispatchQueue.main.async {           self.region = newValue         }       }     )     return Map(coordinateRegion: binding)   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Recommended method of passing NSManagedObjectContext to @ObservedObject/@StateObject
Another way to do that is to pass the context from the view to the ObservableObject whenever needed (with every function call). This will make you easily create unit tests for the view model (the observable object) by testing its functions using a mock context.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to SKScene not showing entirely on the screen
Setting the launch screen resolved my issue. This looks completely unrelated but it solves the issue. Thank you @ chrisl7777777
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Apr ’21