Hi guys
I have the following problem:
I have MapKit view in swiftui where I'm updating a boolean variable so I know when all the data points are displayed.
I have created the following class and I can "see" the variable changing from false to true and vice versa.
The problem is how to use this variable in ContentView so I can turn on and off a spinner.
I have tried several approaches but nothing works.
In MapView I'm doing it the following way
The variable does change when I have everything in the map
But how to use it for the spinner ?
Any ideias please ?
Thank you
I have the following problem:
I have MapKit view in swiftui where I'm updating a boolean variable so I know when all the data points are displayed.
I have created the following class and I can "see" the variable changing from false to true and vice versa.
Code Block class GettingData: ObservableObject { @Published var doneGettingData : Bool = false { didSet { if doneGettingData { print("The instance property doneGettingData is now true.") } else { print("The instance property doneGettingData is now false.") } } } }
The problem is how to use this variable in ContentView so I can turn on and off a spinner.
I have tried several approaches but nothing works.
In MapView I'm doing it the following way
Code Block struct MapView: UIViewRepresentable { let shared = GettingData() var startdate : String var depth: String // The makeUIView(context:) method is creates an empty Map View. func makeUIView(context: Context) -> MKMapView{ MKMapView(frame: .zero) } func makeCoordinator() -> MapViewCoordinator{ MapViewCoordinator(self) } func updateUIView(_ uiView: MKMapView, context: Context){ self.shared.doneGettingData = false \\\\ rest of the code uiView.addAnnotations(allLocations) self.shared.doneGettingData = true \\\\ rest of the code
The variable does change when I have everything in the map
But how to use it for the spinner ?
Any ideias please ?
Thank you