Post

Replies

Boosts

Views

Activity

Reply to MapAnnotation SwiftUI Runtime Warnings
Seems to be that this fixes it (I don't really understand why, so if someone can explain why it works and why the previous way of doing it now doesn't that would be really appreciated) I don't take credit for this, as it was a solution by another user called tonyayoub on the Apple developer forums This is what he found, the code that was producing the warning was: 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