File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 88
99import Foundation
1010
11- public func onMain( _ closure: @escaping ( ) -> ( ) ) {
11+ public func onMain( sync : Bool = false , _ closure: @escaping ( ) -> ( ) ) {
1212 if Thread . isMainThread {
1313 closure ( )
1414 } else {
15- DispatchQueue . main. async ( execute: closure)
15+ sync ? DispatchQueue . main. sync ( execute: closure)
16+ : DispatchQueue . main. async ( execute: closure)
1617 }
1718}
1819
Original file line number Diff line number Diff line change @@ -467,12 +467,19 @@ import LocoKitCore
467467 untimely deaths of small cute animals in Madagascar.
468468 */
469469 @objc public private( set) lazy var locationManager : CLLocationManager = {
470- let manager = CLLocationManager ( )
471- manager. distanceFilter = kCLDistanceFilterNone
472- manager. desiredAccuracy = self . maximumDesiredLocationAccuracy
473- manager. pausesLocationUpdatesAutomatically = false
474-
475- manager. delegate = self
470+ var manager : CLLocationManager !
471+
472+ // Problems may occur if CLLocationManager is not created on the main thread
473+ onMain ( sync: true ) {
474+ manager = CLLocationManager ( )
475+ manager. distanceFilter = kCLDistanceFilterNone
476+ manager. desiredAccuracy = self . maximumDesiredLocationAccuracy
477+ manager. pausesLocationUpdatesAutomatically = false
478+
479+ manager. delegate = self
480+
481+ }
482+
476483 return manager
477484 } ( )
478485
You can’t perform that action at this time.
0 commit comments