0 9

CoreLocatonManager + Rx

Reactive extension for Core Location manager
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
class RxCLLocationManagerDelegateProxy: DelegateProxy, CLLocationManagerDelegate, DelegateProxyType { class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { let locationManager: CLLocationManager = object as! CLLocationManager locationManager.delegate = delegate as? CLLocationManagerDelegate } class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { let locationManager: CLLocationManager = object as! CLLocationManager return locationManager.delegate } } extension Reactive where Base: CLLocationManager { var delegate: DelegateProxy { return RxCLLocationManagerDelegateProxy.proxyForObject(base) } var didUpdateLocations: Observable<[CLLocation]> { return delegate.methodInvoked(#selector(CLLocationManagerDelegate.locationManager(_:didUpdateLocations:))) .map { parameters in return parameters[1] as! [CLLocation] } } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus