core-location

CLLocationCoordinate2D can't be instantiated

做~自己de王妃 提交于 2021-01-20 07:32:10
问题 I am trying to create some "CLLocation"s from data that I've read from a file. The first step is to instantiate a "CLLocationCoordinate2D" to be fed into the initializer for CLLocation. I'm trying out my ideas in a Playground and this very simple code generates a runtime error: import CoreLocation let lat = 48.8 let lon = -122.3 let point2D = CLLocationCoordinate2D(latitude: lat, longitude: lon) Error message is error: Execution was interrupted, reason: signal SIGABRT. The process has been

Fetching current location in iOS 14 Widget

喜夏-厌秋 提交于 2020-12-25 04:02:48
问题 Has anyone tried to update user's location in iOS 14 Widget? After reading Apple Developer forums I've come up with the writing wrapper around CLLocationManager and using it this way: class WidgetLocationManager: NSObject, CLLocationManagerDelegate { var locationManager: CLLocationManager? { didSet { self.locationManager!.delegate = self } } private var handler: ((CLLocation) -> Void)? func fetchLocation(handler: @escaping (CLLocation) -> Void) { self.handler = handler self.locationManager!

How to get Current Location using SwiftUI, without ViewControllers?

牧云@^-^@ 提交于 2020-08-20 18:08:48
问题 I've prepared in my project the following class to retrieve the user current location: LocationManager.swift import Foundation import CoreLocation class LocationManager: NSObject { // - Private private let locationManager = CLLocationManager() // - API public var exposedLocation: CLLocation? { return self.locationManager.location } override init() { super.init() self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager