From bd284c826915ca77c0f52bee82d6a69c145a0aa2 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Mon, 20 Jul 2015 19:19:02 +0200 Subject: [PATCH] Updated to 1.7 --- RxBlocking/RxBlocking/Observable+Blocking.swift | 6 +++--- .../Implementations/KVOObservable.swift | 10 +++++----- .../RxCocoa/Common/Observables/NSObject+Rx.swift | 14 +++++++------- RxCocoa/RxCocoa/iOS/UIControl+Rx.swift | 2 +- RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift | 2 +- RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift | 2 +- RxTests/RxCocoaTests/KVOObservableTests.swift | 4 ++-- RxTests/RxTest.swift | 1 + 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/RxBlocking/RxBlocking/Observable+Blocking.swift b/RxBlocking/RxBlocking/Observable+Blocking.swift index 41cfca7b..f68b66b9 100644 --- a/RxBlocking/RxBlocking/Observable+Blocking.swift +++ b/RxBlocking/RxBlocking/Observable+Blocking.swift @@ -22,7 +22,7 @@ public func toArray(source: Observable) source.subscribeSafe(AnonymousObserver { e in switch e { case .Next(let element): - elements.append(element.value) + elements.append(element) case .Error(let e): error = e condition.lock() @@ -65,7 +65,7 @@ public func first(source: Observable) switch e { case .Next(let e): if element == nil { - element = e.value + element = e } break case .Error(let e): @@ -109,7 +109,7 @@ public func last(source: Observable) d.disposable = source.subscribeSafe(AnonymousObserver { e in switch e { case .Next(let e): - element = e.value + element = e return case .Error(let e): error = e diff --git a/RxCocoa/RxCocoa/Common/Observables/Implementations/KVOObservable.swift b/RxCocoa/RxCocoa/Common/Observables/Implementations/KVOObservable.swift index 7a9423d9..3032ae69 100644 --- a/RxCocoa/RxCocoa/Common/Observables/Implementations/KVOObservable.swift +++ b/RxCocoa/RxCocoa/Common/Observables/Implementations/KVOObservable.swift @@ -46,14 +46,14 @@ class KVOObservable : Producer #if !DISABLE_SWIZZLING -func observeWeaklyKeyPathFor(target: NSObject, # keyPath: String, # options: NSKeyValueObservingOptions) -> Observable { +func observeWeaklyKeyPathFor(target: NSObject, keyPath: String, options: NSKeyValueObservingOptions) -> Observable { let components = keyPath.componentsSeparatedByString(".").filter { $0 != "self" } let observable = observeWeaklyKeyPathFor(target, keyPathSections: components, options: options) >- distinctUntilChanged { $0 === $1 } >- finishWithNilWhenDealloc(target) - if options & .Initial != .allZeros { + if !options.intersect(.Initial).isEmpty { return observable } else { @@ -86,8 +86,8 @@ func finishWithNilWhenDealloc(target: NSObject) func observeWeaklyKeyPathFor( target: NSObject, - # keyPathSections: [String], - # options: NSKeyValueObservingOptions + keyPathSections: [String], + options: NSKeyValueObservingOptions ) -> Observable { weak var weakTarget: AnyObject? = target @@ -103,7 +103,7 @@ func observeWeaklyKeyPathFor( // should dealloc hook be in place if week property, or just create strong reference because it doesn't matter let isWeak = isWeakProperty(String.fromCString(propertyAttributes) ?? "") - let propertyObservable = KVOObservable(object: target, keyPath: propertyName, options: options | .Initial, retainTarget: false) as KVOObservable + let propertyObservable = KVOObservable(object: target, keyPath: propertyName, options: options.union(.Initial), retainTarget: false) as KVOObservable // KVO recursion for value changes return propertyObservable diff --git a/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift b/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift index a8db0646..41734cce 100644 --- a/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift +++ b/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift @@ -41,7 +41,7 @@ extension NSObject { // Observes values on `keyPath` starting from `self` with `.Initial | .New` options. // Retains `self` while observing. public func rx_observe(keyPath: String) -> Observable { - return KVOObservable(object: self, keyPath: keyPath, options: .Initial | .New, retainTarget: true) + return KVOObservable(object: self, keyPath: keyPath, options: NSKeyValueObservingOptions.Initial.union(NSKeyValueObservingOptions.New), retainTarget: true) } // Observes values on `keyPath` starting from `self` with `options` @@ -62,7 +62,7 @@ extension NSObject { // Observes values on `keyPath` starting from `self` with `.Initial | .New` options. // Doesn't retain `self` and when `self` is deallocated, completes the sequence. public func rx_observeWeakly(keyPath: String) -> Observable { - return rx_observeWeakly(keyPath, options: .New | .Initial) + return rx_observeWeakly(keyPath, options: NSKeyValueObservingOptions.New.union(.Initial)) } // Observes values on `keyPath` starting from `self` with `options` @@ -90,8 +90,8 @@ extension NSObject { sendNext(subject, ()) sendCompleted(subject) } - objc_setAssociatedObject(self, &deallocatedSubjectContext, subject, objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) - objc_setAssociatedObject(self, &deallocatedSubjectTriggerContext, deinitAction, objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) + objc_setAssociatedObject(self, &deallocatedSubjectContext, subject, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + objc_setAssociatedObject(self, &deallocatedSubjectTriggerContext, deinitAction, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) return subject } } @@ -113,7 +113,7 @@ extension NSObject { self, &deallocatingSubjectContext, subject, - objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC) + .OBJC_ASSOCIATION_RETAIN_NONATOMIC ) let proxy = Deallocating { @@ -127,12 +127,12 @@ extension NSObject { objc_setAssociatedObject(self, RXDeallocatingAssociatedAction, proxy, - objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC) + .OBJC_ASSOCIATION_RETAIN_NONATOMIC ) objc_setAssociatedObject(self, &deallocatingSubjectTriggerContext, deinitAction, - objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC) + .OBJC_ASSOCIATION_RETAIN_NONATOMIC ) RX_ensure_deallocating_swizzled(self.dynamicType) diff --git a/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift b/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift index d8089bec..7a099c44 100644 --- a/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift +++ b/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift @@ -31,7 +31,7 @@ extension UIControl { sendNext(observer, getValue()) - let controlTarget = ControlTarget(control: self, controlEvents: UIControlEvents.EditingChanged | .ValueChanged) { control in + let controlTarget = ControlTarget(control: self, controlEvents: UIControlEvents.EditingChanged.union(.ValueChanged)) { control in sendNext(observer, getValue()) } diff --git a/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift b/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift index 7c012298..de23d64b 100644 --- a/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift +++ b/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift @@ -24,7 +24,7 @@ extension UIImageView { switch event { case .Next(let boxedValue): - let value = boxedValue.value + let value = boxedValue if animated && value != nil { let transition = CATransition() transition.duration = 0.25 diff --git a/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift b/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift index 3637a127..2929ff39 100644 --- a/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift +++ b/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift @@ -19,7 +19,7 @@ extension UISearchBar { } public var rx_searchText: Observable { - return defer { [weak self] in + return deferred { [weak self] in let text = self?.text ?? "" return self?.rx_delegate.observe("searchBar:textDidChange:") ?? empty() diff --git a/RxTests/RxCocoaTests/KVOObservableTests.swift b/RxTests/RxCocoaTests/KVOObservableTests.swift index 10f3b44a..4b3f4c4e 100644 --- a/RxTests/RxCocoaTests/KVOObservableTests.swift +++ b/RxTests/RxCocoaTests/KVOObservableTests.swift @@ -30,7 +30,7 @@ class Parent : NSObject { init(callback: String? -> Void) { super.init() - self.rx_observe("val", options: .Initial | .New, retainSelf: false) + self.rx_observe("val", options: NSKeyValueObservingOptions.Initial.union(.New), retainSelf: false) >- subscribeNext(callback) >- disposeBag.addDisposable } @@ -45,7 +45,7 @@ class Child : NSObject { init(parent: ParentWithChild, callback: String? -> Void) { super.init() - parent.rx_observe("val", options: .Initial | .New, retainSelf: false) + parent.rx_observe("val", options: NSKeyValueObservingOptions.Initial.union(.New), retainSelf: false) >- subscribeNext(callback) >- disposeBag.addDisposable } diff --git a/RxTests/RxTest.swift b/RxTests/RxTest.swift index 9c22371b..3cdaaced 100644 --- a/RxTests/RxTest.swift +++ b/RxTests/RxTest.swift @@ -8,6 +8,7 @@ import XCTest import RxSwift +import CoreLocation #if TRACE_RESOURCES #elseif RELEASE