Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MainViewModel: ObservableObject {
- @ObservedObject var locationManager = LocationManager()
- var cancellable = AnyCancellable {}
- init() {
- cancellable = locationManager.$lastLocation.sink { location in
- log("location observer", .notification, location?.coordinate) // prints a real location
- if location != nil { // locationManager.lastLocation != nil
- self.updateModels { _ in }
- }
- }
- }
- func updateModels(completion: @escaping (String) -> Void) {
- let coordinates: Coordinates = .init(locationManager.lastLocation!.coordinate) // Unexpectedly found nil while unwrapping an Optional value
- ... // some code
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement