From c4b392c86d75719ded24037a717a6eb8a0ba51db Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Wed, 12 Aug 2015 19:37:07 +0200 Subject: [PATCH] Fix for #89 (CLAuthorizationStatus casting crash) --- RxCocoa/RxCocoa.xcodeproj/project.pbxproj | 4 ++-- RxCocoa/RxCocoa/Common/CLLocationManager+Rx.swift | 4 ++-- .../Examples/APIWrappers/APIWrappersViewController.swift | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RxCocoa/RxCocoa.xcodeproj/project.pbxproj b/RxCocoa/RxCocoa.xcodeproj/project.pbxproj index 4c364efee..2997505e0 100644 --- a/RxCocoa/RxCocoa.xcodeproj/project.pbxproj +++ b/RxCocoa/RxCocoa.xcodeproj/project.pbxproj @@ -156,7 +156,7 @@ C88BB8E31B07F2BE0064D411 /* UILabel+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "UILabel+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C88BB8E41B07F2BE0064D411 /* UIScrollView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "UIScrollView+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C88BB8E51B07F2BE0064D411 /* UISearchBar+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "UISearchBar+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - C88BB8E61B07F2BE0064D411 /* UITableView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "UITableView+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + C88BB8E61B07F2BE0064D411 /* UITableView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "UITableView+Rx.swift"; sourceTree = ""; }; C88BB8E71B07F2BE0064D411 /* UITextField+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "UITextField+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C88BB91B1B07FD830064D411 /* NSButton+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "NSButton+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C8A56BCD1AD744FD00B4673B /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = RxSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -166,7 +166,7 @@ C8C46DAD1B47FD0B0020D71E /* _RXDelegateProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _RXDelegateProxy.h; sourceTree = ""; }; C8C46DAE1B47FD0B0020D71E /* _RXDelegateProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _RXDelegateProxy.m; sourceTree = ""; }; C8CDD7D81B52DA570043F0C5 /* RxCLLocationManagerDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = RxCLLocationManagerDelegateProxy.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - C8CDD7DB1B52DA790043F0C5 /* CLLocationManager+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "CLLocationManager+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + C8CDD7DB1B52DA790043F0C5 /* CLLocationManager+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "CLLocationManager+Rx.swift"; sourceTree = ""; }; C8CDD7DE1B52DAA80043F0C5 /* RxTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = RxTarget.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C8D95C161B2F0CD700FA661F /* DelegateProxyType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = DelegateProxyType.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; CBEEA6781B12323800176529 /* NSSlider+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "NSSlider+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; diff --git a/RxCocoa/RxCocoa/Common/CLLocationManager+Rx.swift b/RxCocoa/RxCocoa/Common/CLLocationManager+Rx.swift index 69dc68b3d..95b8176f0 100644 --- a/RxCocoa/RxCocoa/Common/CLLocationManager+Rx.swift +++ b/RxCocoa/RxCocoa/Common/CLLocationManager+Rx.swift @@ -134,10 +134,10 @@ extension CLLocationManager { // MARK: Responding to Authorization Changes - public var rx_didChangeAuthorizationStatus: Observable { + public var rx_didChangeAuthorizationStatus: Observable { return rx_delegate.observe("locationManager:didChangeAuthorizationStatus:") >- map { a in - return a[1] as! CLAuthorizationStatus + return CLAuthorizationStatus(rawValue: Int32((a[1] as! NSNumber).integerValue)) } } diff --git a/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift b/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift index 27e3791bd..a8b3b444a 100644 --- a/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift +++ b/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift @@ -212,6 +212,12 @@ class APIWrappersViewController: ViewController { >- disposeBag.addDisposable + manager.rx_didChangeAuthorizationStatus + >- subscribeNext { status in + println("Authorization status \(status)") + } + >- disposeBag.addDisposable + manager.startUpdatingLocation()