From f9663df3bf693c930db09919c9ea1eb1a096bc75 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 13 Mar 2016 18:01:39 +0100 Subject: [PATCH 01/17] Fixes compilation of example app. --- .../DataSources/CollectionViewSectionedDataSource.swift | 3 +++ .../DataSources/TableViewSectionedDataSource.swift | 3 +++ 2 files changed, 6 insertions(+) diff --git a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift index 8ad6ebae..6e65c031 100644 --- a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift @@ -8,6 +8,9 @@ import Foundation import UIKit +#if !RX_NO_MODULE + import RxCocoa +#endif public class _CollectionViewSectionedDataSource : NSObject diff --git a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift index 024c7f40..d50c4fc7 100644 --- a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift @@ -8,6 +8,9 @@ import Foundation import UIKit +#if !RX_NO_MODULE + import RxCocoa +#endif // objc monkey business public class _TableViewSectionedDataSource From 09eb8803d4d37c2ceb607c8ec78d9cd15d9a2719 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 13 Mar 2016 18:08:36 +0100 Subject: [PATCH 02/17] Fixes data source link in `GerringStarted.md`. --- Documentation/GettingStarted.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Documentation/GettingStarted.md b/Documentation/GettingStarted.md index 91856923..cde6acb6 100644 --- a/Documentation/GettingStarted.md +++ b/Documentation/GettingStarted.md @@ -1130,12 +1130,10 @@ public struct Logging { } ``` -## RxDataSourceStarterKit +## RxDataSources ... is a set of classes that implement fully functional reactive data sources for `UITableView`s and `UICollectionView`s. -Source code, more information and rationale why these classes are separated into their directory can be found [here](../RxExample/RxDataSourceStarterKit). - -Using them should come down to just importing all of the files into your project. +RxDataSources are bundled [here](https://github.com/RxSwiftCommunity/RxDataSources). Fully functional demonstration how to use them is included in the [RxExample](../RxExample) project. From 439e6bddda8caa2077b065496ad2806bfe721ddd Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 13 Mar 2016 19:53:17 +0100 Subject: [PATCH 03/17] Improves blocking unit tests cleanup logic. --- Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift b/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift index fda27baa..9410f5ce 100644 --- a/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift +++ b/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift @@ -359,5 +359,8 @@ extension ObservableBlockingTest { XCTAssertEqual(c, 1) XCTAssertEqual(d, 1) } + + // add timeout to give time to clean up + sleep(0.3) } } From 4754216ffdead2b8413042e15b7b3d1e30ce7908 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Sun, 13 Mar 2016 19:53:33 +0100 Subject: [PATCH 04/17] Fixes broken link in `GettingStarted.md`. --- Documentation/GettingStarted.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/GettingStarted.md b/Documentation/GettingStarted.md index cde6acb6..cd5c90b0 100644 --- a/Documentation/GettingStarted.md +++ b/Documentation/GettingStarted.md @@ -19,7 +19,7 @@ This project tries to be consistent with [ReactiveX.io](http://reactivex.io/). T 1. [KVO](#kvo) 1. [UI layer tips](#ui-layer-tips) 1. [Making HTTP requests](#making-http-requests) -1. [RxDataSourceStarterKit](#rxdatasourcestarterkit) +1. [RxDataSources](#rxdatasources) 1. [Driver](Units.md#driver-unit) 1. [Examples](Examples.md) From 9e8af26719b429cb1f99f5230d7a67286e41f5b0 Mon Sep 17 00:00:00 2001 From: dakeshi Date: Thu, 17 Mar 2016 18:02:07 +0900 Subject: [PATCH 05/17] Update syntax for RxSwift2.x, Swift2.x --- Documentation/Examples.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/Examples.md b/Documentation/Examples.md index ae81a65b..135898f2 100644 --- a/Documentation/Examples.md +++ b/Documentation/Examples.md @@ -46,7 +46,8 @@ let b /*: Observable*/ = Variable(2) // b = 2 // if a + b >= 0 { // c = "\(a + b) is positive" // } -let c = Observable.combineLatest(a, b) { $0 + $1 } // combines latest values of variables `a` and `b` using `+` +let c = Observable.combineLatest(a.asObservable(), b.asObservable(), + resultSelector: { $0 + $1 }) // combines latest values of variables `a` and `b` using `+` .filter { $0 >= 0 } // if `a + b >= 0` is true, `a + b` is passed to map operator .map { "\($0) is positive" } // maps `a + b` to "\(a + b) is positive" @@ -87,7 +88,7 @@ b.value = -8 // doesn't print anything ```swift let subscription/*: Disposable */ = primeTextField.rx_text // type is Observable - .map { WolframAlphaIsPrime($0.toInt() ?? 0) } // type is Observable> + .map { WolframAlphaIsPrime(Int($0) ?? 0) } // type is Observable> .concat() // type is Observable .map { "number \($0.n) is prime? \($0.isPrime)" } // type is Observable .bindTo(resultLabel.rx_text) // return Disposable that can be used to unbind everything @@ -124,7 +125,7 @@ self.usernameOutlet.rx_text // Convenience for constructing synchronous result. // In case there is mixed synchronous and asychronous code inside the same // method, this will construct an async result that is resolved immediatelly. - return just((valid: false, message: "Username can't be empty.")) + return Observable.just((valid: false, message: "Username can't be empty.")) } ... @@ -136,7 +137,8 @@ self.usernameOutlet.rx_text // * true - is valid // * false - not valid // * nil - validation pending - let loadingValue = (valid: nil, message: "Checking availability ...") + typealias LoadingInfo = (valid : String?, message: String?) + let loadingValue : LoadingInfo = (valid: nil, message: "Checking availability ...") // This will fire a server call to check if the username already exists. // Guess what, its type is `Observable` From a1c2448efe88e45e6fe0818df351b9cdefe41709 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Thu, 17 Mar 2016 10:40:24 +0100 Subject: [PATCH 06/17] Fixes synchronization problem with `SingleAssignmentDisposable`. --- RxSwift/Disposables/SingleAssignmentDisposable.swift | 1 + Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift | 5 +---- Tests/RxTest.swift | 3 ++- scripts/common.sh | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/RxSwift/Disposables/SingleAssignmentDisposable.swift b/RxSwift/Disposables/SingleAssignmentDisposable.swift index a3389c11..9fedf5f5 100644 --- a/RxSwift/Disposables/SingleAssignmentDisposable.swift +++ b/RxSwift/Disposables/SingleAssignmentDisposable.swift @@ -51,6 +51,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable { } private func _setDisposable(newValue: Disposable) -> Disposable? { + _lock.lock(); defer { _lock.unlock() } if _disposableSet { rxFatalError("oldState.disposable != nil") } diff --git a/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift b/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift index 9410f5ce..046827ef 100644 --- a/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift +++ b/Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift @@ -166,7 +166,7 @@ extension ObservableBlockingTest { func testLast_independent() { for i in 0 ..< 10 { - let scheduler = ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .Default) + let scheduler = ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .Background) func operation1()->Observable{ return Observable.just(1).subscribeOn(scheduler) @@ -359,8 +359,5 @@ extension ObservableBlockingTest { XCTAssertEqual(c, 1) XCTAssertEqual(d, 1) } - - // add timeout to give time to clean up - sleep(0.3) } } diff --git a/Tests/RxTest.swift b/Tests/RxTest.swift index 3772ca89..d5f4dbe4 100644 --- a/Tests/RxTest.swift +++ b/Tests/RxTest.swift @@ -91,9 +91,10 @@ extension RxTest { func tearDownActions() { #if TRACE_RESOURCES // give 5 sec to clean up resources - for _ in 0..<10 { + for _ in 0..<30 { if self.startResourceCount < resourceCount { // main schedulers need to finish work + print("Waiting for resource cleanup ...") NSRunLoop.currentRunLoop().runMode(NSDefaultRunLoopMode, beforeDate: NSDate(timeIntervalSinceNow: 0.05)) } else { diff --git a/scripts/common.sh b/scripts/common.sh index 3c459da2..bebf77d0 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -139,7 +139,7 @@ function action() { -configuration "${CONFIGURATION}" \ -derivedDataPath "${BUILD_DIRECTORY}" \ -destination "$DESTINATION" \ - $ACTION | xcpretty -c; STATUS=${PIPESTATUS[0]} + $ACTION | tee build/last-build-output.txt | xcpretty -c; STATUS=${PIPESTATUS[0]} set +x if [ $STATUS -ne 0 ]; then From e8530fffcb69c438bb182be57d168b0e67a06bd6 Mon Sep 17 00:00:00 2001 From: rasad88 Date: Thu, 17 Mar 2016 14:35:23 -0700 Subject: [PATCH 07/17] Add Carthage compatibility badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fa679cc..b239ae0f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ Miss Electric Eel 2016 RxSwift: ReactiveX for Swift ====================================== -[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) +[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + Xcode 7 Swift 2.1 required From 966734d9d7247281c19197d38e4bfd98e0e34793 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Fri, 18 Mar 2016 23:08:52 +0100 Subject: [PATCH 08/17] Updates `CHANGELOG.md`. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 237157f0..59177278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. #### Anomalies +* Fixes anomaly with synchronization in disposable setter of `SingleAssignmentDisposable`. * Improves `DelegateProxy` memory management. * Fixes anomaly during two way binding of `UITextView` text value. * Improves `single` operator so it handles reentrancy better. From 7a561b402c25e839a86c047ee0821248d11b304a Mon Sep 17 00:00:00 2001 From: Vladimir Burdukov Date: Sat, 19 Mar 2016 21:20:32 +0300 Subject: [PATCH 09/17] Make ScheduledDisposable initializer public --- RxSwift/Disposables/ScheduledDisposable.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RxSwift/Disposables/ScheduledDisposable.swift b/RxSwift/Disposables/ScheduledDisposable.swift index 03c7e695..ac734996 100644 --- a/RxSwift/Disposables/ScheduledDisposable.swift +++ b/RxSwift/Disposables/ScheduledDisposable.swift @@ -37,7 +37,7 @@ public class ScheduledDisposable : Cancelable { - parameter scheduler: Scheduler where the disposable resource will be disposed on. - parameter disposable: Disposable resource to dispose on the given scheduler. */ - init(scheduler: ImmediateSchedulerType, disposable: Disposable) { + public init(scheduler: ImmediateSchedulerType, disposable: Disposable) { self.scheduler = scheduler _disposable = disposable } From e5be80763dd70711d6ca9d22daf3b7b5b80c2b00 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Thu, 4 Feb 2016 16:11:07 +0100 Subject: [PATCH 10/17] Use StaticString for file in XCTest helpers --- RxTests/XCTest+Rx.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RxTests/XCTest+Rx.swift b/RxTests/XCTest+Rx.swift index 481b78c7..e96d7afc 100644 --- a/RxTests/XCTest+Rx.swift +++ b/RxTests/XCTest+Rx.swift @@ -58,7 +58,7 @@ Event is considered equal if: - parameter lhs: first set of events. - parameter lhs: second set of events. */ -public func XCTAssertEqual(lhs: [Event], _ rhs: [Event], file: String = __FILE__, line: UInt = __LINE__) { +public func XCTAssertEqual(lhs: [Event], _ rhs: [Event], file: StaticString = __FILE__, line: UInt = __LINE__) { let leftEquatable = lhs.map { AnyEquatable(target: $0, comparer: ==) } let rightEquatable = rhs.map { AnyEquatable(target: $0, comparer: ==) } #if os(Linux) @@ -86,7 +86,7 @@ Event is considered equal if: - parameter lhs: first set of events. - parameter lhs: second set of events. */ -public func XCTAssertEqual(lhs: [Recorded>], _ rhs: [Recorded>], file: String = __FILE__, line: UInt = __LINE__) { +public func XCTAssertEqual(lhs: [Recorded>], _ rhs: [Recorded>], file: StaticString = __FILE__, line: UInt = __LINE__) { let leftEquatable = lhs.map { AnyEquatable(target: $0, comparer: ==) } let rightEquatable = rhs.map { AnyEquatable(target: $0, comparer: ==) } #if os(Linux) From 6cd3d53b4b7bacf498a9b8cf9e939dd8787c7329 Mon Sep 17 00:00:00 2001 From: Douglas Heriot Date: Fri, 19 Feb 2016 22:33:51 +1100 Subject: [PATCH 11/17] Change anyGenerator to AnyGenerator for Swift 2.2 (Xcode 7.3) --- RxSwift/DataStructures/InfiniteSequence.swift | 2 +- RxSwift/DataStructures/Queue.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RxSwift/DataStructures/InfiniteSequence.swift b/RxSwift/DataStructures/InfiniteSequence.swift index 29ec22a5..a594bb5b 100644 --- a/RxSwift/DataStructures/InfiniteSequence.swift +++ b/RxSwift/DataStructures/InfiniteSequence.swift @@ -23,7 +23,7 @@ struct InfiniteSequence : SequenceType { func generate() -> Generator { let repeatedValue = _repeatedValue - return anyGenerator { + return AnyGenerator { return repeatedValue } } diff --git a/RxSwift/DataStructures/Queue.swift b/RxSwift/DataStructures/Queue.swift index 3b97b5f0..f38d4ae7 100644 --- a/RxSwift/DataStructures/Queue.swift +++ b/RxSwift/DataStructures/Queue.swift @@ -156,7 +156,7 @@ public struct Queue: SequenceType { var i = dequeueIndex var count = _count - return anyGenerator { + return AnyGenerator { if count == 0 { return nil } From 24af30f32aab2ac4b523bb1fdcc8497996e4d3ea Mon Sep 17 00:00:00 2001 From: Yosuke Ishikawa Date: Tue, 22 Mar 2016 15:35:11 +0900 Subject: [PATCH 12/17] Workaround for segmentation fault in CurrentThreadScheduler.schedule() --- RxSwift/Schedulers/CurrentThreadScheduler.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/RxSwift/Schedulers/CurrentThreadScheduler.swift b/RxSwift/Schedulers/CurrentThreadScheduler.swift index 0a91f234..16882fe6 100644 --- a/RxSwift/Schedulers/CurrentThreadScheduler.swift +++ b/RxSwift/Schedulers/CurrentThreadScheduler.swift @@ -139,6 +139,11 @@ public class CurrentThreadScheduler : ImmediateSchedulerType { let scheduledItem = ScheduledItem(action: action, state: state) queue.value.enqueue(scheduledItem) - return scheduledItem + + // In Xcode 7.3, `return scheduledItem` causes segmentation fault 11 on release build. + // To workaround this compiler issue, returns AnonymousDisposable that disposes scheduledItem. + return AnonymousDisposable { + scheduledItem.dispose() + } } } From 4df2711aee83d40885bff0beafaa7e24df32318d Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Tue, 22 Mar 2016 10:18:01 +0100 Subject: [PATCH 13/17] Updates travis to xcode7.3 image. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0dd1116c..d08e3900 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: objective-c -osx_image: xcode7.2 +osx_image: xcode7.3 notifications: slack: rxswift:3ykt2Z61f8GkdvhCZTYPduOL From eddbd23aa56e0bc1069f0d3d590a979481b4d041 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Tue, 22 Mar 2016 08:43:04 +0100 Subject: [PATCH 14/17] Use new associatedtype syntax --- Documentation/Schedulers.md | 4 ++-- RxCocoa/Common/KVORepresentable.swift | 2 +- RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift | 2 +- RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift | 2 +- RxExample/RxDataSources/DataSources/SectionModelType.swift | 2 +- RxSwift/Concurrency/SynchronizedUnsubscribeType.swift | 2 +- RxSwift/ObservableConvertibleType.swift | 2 +- RxSwift/ObservableType.swift | 2 +- RxSwift/ObserverType.swift | 2 +- RxSwift/Schedulers/Internal/InvocableType.swift | 2 +- RxSwift/Schedulers/VirtualTimeConverterType.swift | 4 ++-- RxSwift/Subjects/SubjectType.swift | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Documentation/Schedulers.md b/Documentation/Schedulers.md index 95c4589c..aa465be9 100644 --- a/Documentation/Schedulers.md +++ b/Documentation/Schedulers.md @@ -67,8 +67,8 @@ If you want to create new scheduler that supports time based operations, then yo ```swift public protocol Scheduler: ImmediateScheduler { - typealias TimeInterval - typealias Time + associatedtype TimeInterval + associatedtype Time var now : Time { get diff --git a/RxCocoa/Common/KVORepresentable.swift b/RxCocoa/Common/KVORepresentable.swift index 9f4d6067..c51774b3 100644 --- a/RxCocoa/Common/KVORepresentable.swift +++ b/RxCocoa/Common/KVORepresentable.swift @@ -15,7 +15,7 @@ public protocol KVORepresentable { /** Associated KVO type. */ - typealias KVOType + associatedtype KVOType /** Constructs `Self` using KVO value. diff --git a/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift b/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift index abf9a55e..8ff42f6a 100644 --- a/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift +++ b/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift @@ -22,7 +22,7 @@ public protocol RxCollectionViewDataSourceType /*: UICollectionViewDataSource*/ /** Type of elements that can be bound to collection view. */ - typealias Element + associatedtype Element /** New observable sequence event observed. diff --git a/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift b/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift index 4fa18380..e68d896c 100644 --- a/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift +++ b/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift @@ -22,7 +22,7 @@ public protocol RxTableViewDataSourceType /*: UITableViewDataSource*/ { /** Type of elements that can be bound to table view. */ - typealias Element + associatedtype Element /** New observable sequence event observed. diff --git a/RxExample/RxDataSources/DataSources/SectionModelType.swift b/RxExample/RxDataSources/DataSources/SectionModelType.swift index 4d40e1c7..f62bcc9f 100644 --- a/RxExample/RxDataSources/DataSources/SectionModelType.swift +++ b/RxExample/RxDataSources/DataSources/SectionModelType.swift @@ -9,7 +9,7 @@ import Foundation public protocol SectionModelType { - typealias Item + associatedtype Item var items: [Item] { get } } \ No newline at end of file diff --git a/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift b/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift index 3bb68495..4f41cb89 100644 --- a/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift +++ b/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift @@ -9,7 +9,7 @@ import Foundation protocol SynchronizedUnsubscribeType : class { - typealias DisposeKey + associatedtype DisposeKey func synchronizedUnsubscribe(disposeKey: DisposeKey) } \ No newline at end of file diff --git a/RxSwift/ObservableConvertibleType.swift b/RxSwift/ObservableConvertibleType.swift index 6cc3046b..a749a067 100644 --- a/RxSwift/ObservableConvertibleType.swift +++ b/RxSwift/ObservableConvertibleType.swift @@ -15,7 +15,7 @@ public protocol ObservableConvertibleType { /** Type of elements in sequence. */ - typealias E + associatedtype E /** Converts `self` to `Observable` sequence. diff --git a/RxSwift/ObservableType.swift b/RxSwift/ObservableType.swift index 7594bc51..93723e38 100644 --- a/RxSwift/ObservableType.swift +++ b/RxSwift/ObservableType.swift @@ -15,7 +15,7 @@ public protocol ObservableType : ObservableConvertibleType { /** Type of elements in sequence. */ - typealias E + associatedtype E /** Subscribes `observer` to receive events for this sequence. diff --git a/RxSwift/ObserverType.swift b/RxSwift/ObserverType.swift index e9b7a282..396d167c 100644 --- a/RxSwift/ObserverType.swift +++ b/RxSwift/ObserverType.swift @@ -15,7 +15,7 @@ public protocol ObserverType { /** The type of elements in sequence that observer can observe. */ - typealias E + associatedtype E /** Notify observer about sequence event. diff --git a/RxSwift/Schedulers/Internal/InvocableType.swift b/RxSwift/Schedulers/Internal/InvocableType.swift index 0f1bcee7..1632e71d 100644 --- a/RxSwift/Schedulers/Internal/InvocableType.swift +++ b/RxSwift/Schedulers/Internal/InvocableType.swift @@ -13,7 +13,7 @@ protocol InvocableType { } protocol InvocableWithValueType { - typealias Value + associatedtype Value func invoke(value: Value) } \ No newline at end of file diff --git a/RxSwift/Schedulers/VirtualTimeConverterType.swift b/RxSwift/Schedulers/VirtualTimeConverterType.swift index 1af28975..ab506c4e 100644 --- a/RxSwift/Schedulers/VirtualTimeConverterType.swift +++ b/RxSwift/Schedulers/VirtualTimeConverterType.swift @@ -15,12 +15,12 @@ public protocol VirtualTimeConverterType { /** Virtual time unit used that represents ticks of virtual clock. */ - typealias VirtualTimeUnit + associatedtype VirtualTimeUnit /** Virtual time unit used to represent differences of virtual times. */ - typealias VirtualTimeIntervalUnit + associatedtype VirtualTimeIntervalUnit /** Converts virtual time to real time. diff --git a/RxSwift/Subjects/SubjectType.swift b/RxSwift/Subjects/SubjectType.swift index 7f6575cd..51bdfebe 100644 --- a/RxSwift/Subjects/SubjectType.swift +++ b/RxSwift/Subjects/SubjectType.swift @@ -17,7 +17,7 @@ public protocol SubjectType : ObservableType { Usually this type is type of subject itself, but it doesn't have to be. */ - typealias SubjectObserverType : ObserverType + associatedtype SubjectObserverType : ObserverType /** Returns observer interface for subject. From 834cd872f5cb2db1a7293548a0aaffb9ba7fdff2 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Tue, 22 Mar 2016 11:20:10 +0100 Subject: [PATCH 15/17] Updates data sources. --- ...ctionedViewType+RxAnimatedDataSource.swift | 16 ++++++---- .../DataSources/AnimatableSectionModel.swift | 4 +-- .../AnimatableSectionModelType.swift | 2 +- .../CollectionViewSectionedDataSource.swift | 15 +++++---- .../DataSources/IdentifiableType.swift | 2 +- .../DataSources/IdentifiableValue.swift | 4 +-- .../TableViewSectionedDataSource.swift | 31 +++++++++++++------ RxExample/RxExample/Example.swift | 2 +- .../GitHubSearchRepositoriesAPI.swift | 2 +- RxExample/RxExample/Services/Randomizer.swift | 6 ++-- RxSwift/Observables/Observable+Debug.swift | 2 +- 11 files changed, 52 insertions(+), 34 deletions(-) diff --git a/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift b/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift index b4769879..a082117e 100644 --- a/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift +++ b/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift @@ -23,10 +23,12 @@ extension UITableView { O.E == [Section] > (dataSource: DataSource) - (source: O) + -> (source: O) -> Disposable { - let differences = source.differentiateForSectionedView() - return self.rx_itemsWithDataSource(dataSource)(source: differences) + return { source in + let differences = source.differentiateForSectionedView() + return self.rx_itemsWithDataSource(dataSource)(source: differences) + } } } @@ -40,9 +42,11 @@ extension UICollectionView { O.E == [Section] > (dataSource: DataSource) - (source: O) + -> (source: O) -> Disposable { - let differences = source.differentiateForSectionedView() - return self.rx_itemsWithDataSource(dataSource)(source: differences) + return { source in + let differences = source.differentiateForSectionedView() + return self.rx_itemsWithDataSource(dataSource)(source: differences) + } } } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift b/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift index 0a319ca1..cb286844 100644 --- a/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift +++ b/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift @@ -12,7 +12,7 @@ public struct AnimatableSectionModel : Hashable , AnimatableSectionModelType , CustomStringConvertible { - public typealias Item = IdentitifiableValue + public typealias Item = IdentifiableValue public typealias Identity = Section public var model: Section @@ -25,7 +25,7 @@ public struct AnimatableSectionModel public init(model: Section, items: [ItemType]) { self.model = model - self.items = items.map(IdentitifiableValue.init) + self.items = items.map(IdentifiableValue.init) } public init(original: AnimatableSectionModel, items: [Item]) { diff --git a/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift b/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift index aad0f405..c069d000 100644 --- a/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift +++ b/RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift @@ -11,7 +11,7 @@ import Foundation public protocol AnimatableSectionModelType : SectionModelType , IdentifiableType { - typealias Item : IdentifiableType, Equatable + associatedtype Item : IdentifiableType, Equatable init(original: Self, items: [Item]) } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift index 6e65c031..ee35fbac 100644 --- a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift @@ -8,9 +8,7 @@ import Foundation import UIKit -#if !RX_NO_MODULE - import RxCocoa -#endif +import RxCocoa public class _CollectionViewSectionedDataSource : NSObject @@ -144,13 +142,18 @@ public class CollectionViewSectionedDataSource } override func _collectionView(collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: NSIndexPath) -> Bool { - return canMoveItemAtIndexPath?(self, indexPath: indexPath) ?? - super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath) + guard let canMoveItem = canMoveItemAtIndexPath?(self, indexPath: indexPath) else { + return super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath) + } + + return canMoveItem } override func _collectionView(collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) { - return moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) ?? + guard let _ = moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) else { super._collectionView(collectionView, moveItemAtIndexPath: sourceIndexPath, toIndexPath: destinationIndexPath) + return + } } } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/IdentifiableType.swift b/RxExample/RxDataSources/DataSources/IdentifiableType.swift index b5efe3aa..9bda0689 100644 --- a/RxExample/RxDataSources/DataSources/IdentifiableType.swift +++ b/RxExample/RxDataSources/DataSources/IdentifiableType.swift @@ -9,7 +9,7 @@ import Foundation public protocol IdentifiableType { - typealias Identity: Hashable + associatedtype Identity: Hashable var identity : Identity { get } } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/IdentifiableValue.swift b/RxExample/RxDataSources/DataSources/IdentifiableValue.swift index ded89cc0..b6ab1385 100644 --- a/RxExample/RxDataSources/DataSources/IdentifiableValue.swift +++ b/RxExample/RxDataSources/DataSources/IdentifiableValue.swift @@ -8,7 +8,7 @@ import Foundation -public struct IdentitifiableValue +public struct IdentifiableValue : IdentifiableType , Equatable , CustomStringConvertible @@ -30,6 +30,6 @@ public struct IdentitifiableValue } } -public func == (lhs: IdentitifiableValue, rhs: IdentitifiableValue) -> Bool { +public func == (lhs: IdentifiableValue, rhs: IdentifiableValue) -> Bool { return lhs.value == rhs.value } \ No newline at end of file diff --git a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift index d50c4fc7..1723f559 100644 --- a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift @@ -8,9 +8,7 @@ import Foundation import UIKit -#if !RX_NO_MODULE - import RxCocoa -#endif +import RxCocoa // objc monkey business public class _TableViewSectionedDataSource @@ -179,22 +177,35 @@ public class RxTableViewSectionedDataSource } override func _tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { - return canEditRowAtIndexPath?(self, indexPath: indexPath) ?? - super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + guard let canEditRow = canEditRowAtIndexPath?(self, indexPath: indexPath) else { + return super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + } + + return canEditRow } override func _tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { - return canMoveRowAtIndexPath?(self, indexPath: indexPath) ?? - super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + guard let canMoveRow = canMoveRowAtIndexPath?(self, indexPath: indexPath) else { + return super._tableView(tableView, canMoveRowAtIndexPath: indexPath) + } + + return canMoveRow } override func _sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { - return sectionIndexTitles?(self) ?? super._sectionIndexTitlesForTableView(tableView) + guard let titles = sectionIndexTitles?(self) else { + return super._sectionIndexTitlesForTableView(tableView) + } + + return titles } override func _tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { - return sectionForSectionIndexTitle?(self, title: title, index: index) ?? - super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) + guard let section = sectionForSectionIndexTitle?(self, title: title, index: index) else { + return super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) + } + + return section } } diff --git a/RxExample/RxExample/Example.swift b/RxExample/RxExample/Example.swift index 2b9a810d..2f728caf 100644 --- a/RxExample/RxExample/Example.swift +++ b/RxExample/RxExample/Example.swift @@ -19,7 +19,7 @@ import Foundation let MB = 1024 * 1024 -func exampleError(error: String, location: String = "\(__FILE__):\(__LINE__)") -> NSError { +func exampleError(error: String, location: String = "\(#file):\(#line)") -> NSError { return NSError(domain: "ExampleError", code: -1, userInfo: [NSLocalizedDescriptionKey: "\(location): \(error)"]) } diff --git a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift index e3b834ec..4f021f75 100644 --- a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift +++ b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift @@ -202,7 +202,7 @@ extension GitHubSearchRepositoriesAPI { let range = m.rangeAtIndex(rangeIndex) let startIndex = links.startIndex.advancedBy(range.location) let endIndex = startIndex.advancedBy(range.length) - let stringRange = Range(start: startIndex, end: endIndex) + let stringRange = startIndex ..< endIndex return links.substringWithRange(stringRange) } diff --git a/RxExample/RxExample/Services/Randomizer.swift b/RxExample/RxExample/Services/Randomizer.swift index 24cb5282..2afd271a 100644 --- a/RxExample/RxExample/Services/Randomizer.swift +++ b/RxExample/RxExample/Services/Randomizer.swift @@ -74,7 +74,7 @@ class Randomizer { if rng.get_random() % 2 == 0 { let itemIndex = rng.get_random() % (itemCount + 1) if insertItems { - sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: itemIndex) + sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: itemIndex) } else { nextUnusedItems.append(unusedValue) @@ -83,14 +83,14 @@ class Randomizer { // update else { if itemCount == 0 { - sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: 0) + sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: 0) continue } let itemIndex = rng.get_random() % itemCount if reloadItems { nextUnusedItems.append(sections[sectionIndex].items.removeAtIndex(itemIndex).value) - sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: itemIndex) + sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: itemIndex) } else { diff --git a/RxSwift/Observables/Observable+Debug.swift b/RxSwift/Observables/Observable+Debug.swift index 41da70aa..2aa355c0 100644 --- a/RxSwift/Observables/Observable+Debug.swift +++ b/RxSwift/Observables/Observable+Debug.swift @@ -21,7 +21,7 @@ extension ObservableType { - returns: An observable sequence whose events are printed to standard output. */ @warn_unused_result(message="http://git.io/rxs.uo") - public func debug(identifier: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: String = __FUNCTION__) + public func debug(identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) -> Observable { return Debug(source: self.asObservable(), identifier: identifier, file: file, line: line, function: function) } From 65644c6160a64284015f8e8bf9f6c21233b7df30 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Tue, 22 Mar 2016 11:29:39 +0100 Subject: [PATCH 16/17] Fixes Swift 2.2 warnings. --- RxCocoa/Common/CLLocationManager+Rx.swift | 30 +++++++++---------- .../CocoaUnits/Driver/Driver+Operators.swift | 2 +- .../Implementations/ControlTarget.swift | 2 +- RxCocoa/Common/Observables/NSObject+Rx.swift | 4 +-- RxCocoa/iOS/NSTextStorage+Rx.swift | 2 +- RxCocoa/iOS/UIBarButtonItem+Rx.swift | 2 +- RxCocoa/iOS/UICollectionView+Rx.swift | 4 +-- RxCocoa/iOS/UIGestureRecognizer+Rx.swift | 2 +- RxCocoa/iOS/UIImagePickerController+Rx.swift | 4 +-- RxCocoa/iOS/UISearchBar+Rx.swift | 4 +-- RxCocoa/iOS/UITableView+Rx.swift | 12 ++++---- RxExample/RxExample.xcodeproj/project.pbxproj | 2 +- RxTests/XCTest+Rx.swift | 4 +-- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/RxCocoa/Common/CLLocationManager+Rx.swift b/RxCocoa/Common/CLLocationManager+Rx.swift index 82a1a277..47ba0562 100644 --- a/RxCocoa/Common/CLLocationManager+Rx.swift +++ b/RxCocoa/Common/CLLocationManager+Rx.swift @@ -29,7 +29,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didUpdateLocations: Observable<[CLLocation]> { - return rx_delegate.observe("locationManager:didUpdateLocations:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didUpdateLocations:))) .map { a in return try castOrThrow([CLLocation].self, a[1]) } @@ -39,7 +39,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didFailWithError: Observable { - return rx_delegate.observe("locationManager:didFailWithError:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didFailWithError:))) .map { a in return try castOrThrow(NSError.self, a[1]) } @@ -50,7 +50,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didFinishDeferredUpdatesWithError: Observable { - return rx_delegate.observe("locationManager:didFinishDeferredUpdatesWithError:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didFinishDeferredUpdatesWithError:))) .map { a in return try castOptionalOrThrow(NSError.self, a[1]) } @@ -65,7 +65,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didPauseLocationUpdates: Observable { - return rx_delegate.observe("locationManagerDidPauseLocationUpdates:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManagerDidPauseLocationUpdates(_:))) .map { _ in return () } @@ -75,7 +75,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didResumeLocationUpdates: Observable { - return rx_delegate.observe("locationManagerDidResumeLocationUpdates:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManagerDidResumeLocationUpdates(_:))) .map { _ in return () } @@ -87,7 +87,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didUpdateHeading: Observable { - return rx_delegate.observe("locationManager:didUpdateHeading:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didUpdateHeading:))) .map { a in return try castOrThrow(CLHeading.self, a[1]) } @@ -99,7 +99,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didEnterRegion: Observable { - return rx_delegate.observe("locationManager:didEnterRegion:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didEnterRegion:))) .map { a in return try castOrThrow(CLRegion.self, a[1]) } @@ -109,7 +109,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didExitRegion: Observable { - return rx_delegate.observe("locationManager:didExitRegion:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didExitRegion:))) .map { a in return try castOrThrow(CLRegion.self, a[1]) } @@ -124,7 +124,7 @@ extension CLLocationManager { */ @available(OSX 10.10, *) public var rx_didDetermineStateForRegion: Observable<(state: CLRegionState, region: CLRegion)> { - return rx_delegate.observe("locationManager:didDetermineState:forRegion:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didDetermineState:forRegion:))) .map { a in let stateNumber = try castOrThrow(NSNumber.self, a[1]) let state = CLRegionState(rawValue: stateNumber.integerValue) ?? CLRegionState.Unknown @@ -137,7 +137,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_monitoringDidFailForRegionWithError: Observable<(region: CLRegion?, error: NSError)> { - return rx_delegate.observe("locationManager:monitoringDidFailForRegion:withError:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:monitoringDidFailForRegion:withError:))) .map { a in let region = try castOptionalOrThrow(CLRegion.self, a[1]) let error = try castOrThrow(NSError.self, a[2]) @@ -149,7 +149,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didStartMonitoringForRegion: Observable { - return rx_delegate.observe("locationManager:didStartMonitoringForRegion:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didStartMonitoringForRegion:))) .map { a in return try castOrThrow(CLRegion.self, a[1]) } @@ -165,7 +165,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didRangeBeaconsInRegion: Observable<(beacons: [CLBeacon], region: CLBeaconRegion)> { - return rx_delegate.observe("locationManager:didRangeBeacons:inRegion:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didRangeBeacons:inRegion:))) .map { a in let beacons = try castOrThrow([CLBeacon].self, a[1]) let region = try castOrThrow(CLBeaconRegion.self, a[2]) @@ -177,7 +177,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_rangingBeaconsDidFailForRegionWithError: Observable<(region: CLBeaconRegion, error: NSError)> { - return rx_delegate.observe("locationManager:rangingBeaconsDidFailForRegion:withError:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:rangingBeaconsDidFailForRegion:withError:))) .map { a in let region = try castOrThrow(CLBeaconRegion.self, a[1]) let error = try castOrThrow(NSError.self, a[2]) @@ -192,7 +192,7 @@ extension CLLocationManager { */ @available(iOS 8.0, *) public var rx_didVisit: Observable { - return rx_delegate.observe("locationManager:didVisit:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didVisit:))) .map { a in return try castOrThrow(CLVisit.self, a[1]) } @@ -206,7 +206,7 @@ extension CLLocationManager { Reactive wrapper for `delegate` message. */ public var rx_didChangeAuthorizationStatus: Observable { - return rx_delegate.observe("locationManager:didChangeAuthorizationStatus:") + return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didChangeAuthorizationStatus:))) .map { a in let number = try castOrThrow(NSNumber.self, a[1]) return CLAuthorizationStatus(rawValue: Int32(number.integerValue)) ?? .NotDetermined diff --git a/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift b/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift index 039a75b5..c3fb7320 100644 --- a/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift +++ b/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift @@ -180,7 +180,7 @@ extension DriverConvertibleType { - returns: An observable sequence whose events are printed to standard output. */ @warn_unused_result(message="http://git.io/rxs.uo") - public func debug(identifier: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: String = __FUNCTION__) -> Driver { + public func debug(identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) -> Driver { let source = self.asObservable() .debug(identifier, file: file, line: line, function: function) return Driver(source) diff --git a/RxCocoa/Common/Observables/Implementations/ControlTarget.swift b/RxCocoa/Common/Observables/Implementations/ControlTarget.swift index d1b6baa8..91a44b57 100644 --- a/RxCocoa/Common/Observables/Implementations/ControlTarget.swift +++ b/RxCocoa/Common/Observables/Implementations/ControlTarget.swift @@ -28,7 +28,7 @@ import RxSwift class ControlTarget: RxTarget { typealias Callback = (Control) -> Void - let selector: Selector = "eventHandler:" + let selector: Selector = #selector(GestureTarget.eventHandler(_:)) weak var control: Control? #if os(iOS) || os(tvOS) diff --git a/RxCocoa/Common/Observables/NSObject+Rx.swift b/RxCocoa/Common/Observables/NSObject+Rx.swift index 525ed4f3..263647dd 100644 --- a/RxCocoa/Common/Observables/NSObject+Rx.swift +++ b/RxCocoa/Common/Observables/NSObject+Rx.swift @@ -208,8 +208,8 @@ extension NSObject { #endif } -let deallocSelector = "dealloc" as Selector -let rxDeallocatingSelector = RX_selector("dealloc") +let deallocSelector = NSSelectorFromString("dealloc") +let rxDeallocatingSelector = RX_selector(deallocSelector) let rxDeallocatingSelectorReference = RX_reference_from_selector(rxDeallocatingSelector) extension NSObject { diff --git a/RxCocoa/iOS/NSTextStorage+Rx.swift b/RxCocoa/iOS/NSTextStorage+Rx.swift index 15a65ad5..b2c933b5 100644 --- a/RxCocoa/iOS/NSTextStorage+Rx.swift +++ b/RxCocoa/iOS/NSTextStorage+Rx.swift @@ -30,7 +30,7 @@ extension NSTextStorage { */ public var rx_didProcessEditingRangeChangeInLength: Observable<(editedMask:NSTextStorageEditActions, editedRange:NSRange, delta:Int)> { return rx_delegate - .observe("textStorage:didProcessEditing:range:changeInLength:") + .observe(#selector(NSTextStorageDelegate.textStorage(_:didProcessEditing:range:changeInLength:))) .map { a in let editedMask = NSTextStorageEditActions(rawValue: try castOrThrow(UInt.self, a[1]) ) let editedRange = try castOrThrow(NSValue.self, a[2]).rangeValue diff --git a/RxCocoa/iOS/UIBarButtonItem+Rx.swift b/RxCocoa/iOS/UIBarButtonItem+Rx.swift index ef45e73d..a77462f4 100644 --- a/RxCocoa/iOS/UIBarButtonItem+Rx.swift +++ b/RxCocoa/iOS/UIBarButtonItem+Rx.swift @@ -62,7 +62,7 @@ class BarButtonItemTarget: RxTarget { self.callback = callback super.init() barButtonItem.target = self - barButtonItem.action = Selector("action:") + barButtonItem.action = #selector(BarButtonItemTarget.action(_:)) } override func dispose() { diff --git a/RxCocoa/iOS/UICollectionView+Rx.swift b/RxCocoa/iOS/UICollectionView+Rx.swift index 4bd618f7..f5c8a895 100644 --- a/RxCocoa/iOS/UICollectionView+Rx.swift +++ b/RxCocoa/iOS/UICollectionView+Rx.swift @@ -133,7 +133,7 @@ extension UICollectionView { Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`. */ public var rx_itemSelected: ControlEvent { - let source = rx_delegate.observe("collectionView:didSelectItemAtIndexPath:") + let source = rx_delegate.observe(#selector(UICollectionViewDelegate.collectionView(_:didSelectItemAtIndexPath:))) .map { a in return a[1] as! NSIndexPath } @@ -145,7 +145,7 @@ extension UICollectionView { Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`. */ public var rx_itemDeselected: ControlEvent { - let source = rx_delegate.observe("collectionView:didDeselectItemAtIndexPath:") + let source = rx_delegate.observe(#selector(UICollectionViewDelegate.collectionView(_:didDeselectItemAtIndexPath:))) .map { a in return a[1] as! NSIndexPath } diff --git a/RxCocoa/iOS/UIGestureRecognizer+Rx.swift b/RxCocoa/iOS/UIGestureRecognizer+Rx.swift index 97fa8a69..65e6e24b 100644 --- a/RxCocoa/iOS/UIGestureRecognizer+Rx.swift +++ b/RxCocoa/iOS/UIGestureRecognizer+Rx.swift @@ -18,7 +18,7 @@ import RxSwift class GestureTarget: RxTarget { typealias Callback = (UIGestureRecognizer) -> Void - let selector = Selector("eventHandler:") + let selector = #selector(ControlTarget.eventHandler(_:)) weak var gestureRecognizer: UIGestureRecognizer? var callback: Callback? diff --git a/RxCocoa/iOS/UIImagePickerController+Rx.swift b/RxCocoa/iOS/UIImagePickerController+Rx.swift index aa4a3f3f..8e239359 100644 --- a/RxCocoa/iOS/UIImagePickerController+Rx.swift +++ b/RxCocoa/iOS/UIImagePickerController+Rx.swift @@ -32,7 +32,7 @@ import Foundation */ public var rx_didFinishPickingMediaWithInfo: Observable<[String : AnyObject]> { return rx_delegate - .observe("imagePickerController:didFinishPickingMediaWithInfo:") + .observe(#selector(UIImagePickerControllerDelegate.imagePickerController(_:didFinishPickingMediaWithInfo:))) .map({ (a) in return try castOrThrow(Dictionary.self, a[1]) }) @@ -43,7 +43,7 @@ import Foundation */ public var rx_didCancel: Observable<()> { return rx_delegate - .observe("imagePickerControllerDidCancel:") + .observe(#selector(UIImagePickerControllerDelegate.imagePickerControllerDidCancel(_:))) .map {_ in () } } diff --git a/RxCocoa/iOS/UISearchBar+Rx.swift b/RxCocoa/iOS/UISearchBar+Rx.swift index c93055f1..038aca36 100644 --- a/RxCocoa/iOS/UISearchBar+Rx.swift +++ b/RxCocoa/iOS/UISearchBar+Rx.swift @@ -34,7 +34,7 @@ extension UISearchBar { let source: Observable = Observable.deferred { [weak self] () -> Observable in let text = self?.text ?? "" - return (self?.rx_delegate.observe("searchBar:textDidChange:") ?? Observable.empty()) + return (self?.rx_delegate.observe(#selector(UISearchBarDelegate.searchBar(_:textDidChange:))) ?? Observable.empty()) .map { a in return a[1] as? String ?? "" } @@ -55,7 +55,7 @@ extension UISearchBar { let source: Observable = Observable.deferred { [weak self] () -> Observable in let index = self?.selectedScopeButtonIndex ?? 0 - return (self?.rx_delegate.observe("searchBar:selectedScopeButtonIndexDidChange:") ?? Observable.empty()) + return (self?.rx_delegate.observe(#selector(UISearchBarDelegate.searchBar(_:selectedScopeButtonIndexDidChange:))) ?? Observable.empty()) .map { a in return try castOrThrow(Int.self, a[1]) } diff --git a/RxCocoa/iOS/UITableView+Rx.swift b/RxCocoa/iOS/UITableView+Rx.swift index 28bc25ac..9a7ec666 100644 --- a/RxCocoa/iOS/UITableView+Rx.swift +++ b/RxCocoa/iOS/UITableView+Rx.swift @@ -135,7 +135,7 @@ extension UITableView { Reactive wrapper for `delegate` message `tableView:didSelectRowAtIndexPath:`. */ public var rx_itemSelected: ControlEvent { - let source = rx_delegate.observe("tableView:didSelectRowAtIndexPath:") + let source = rx_delegate.observe(#selector(UITableViewDelegate.tableView(_:didSelectRowAtIndexPath:))) .map { a in return a[1] as! NSIndexPath } @@ -147,7 +147,7 @@ extension UITableView { Reactive wrapper for `delegate` message `tableView:didDeselectRowAtIndexPath:`. */ public var rx_itemDeselected: ControlEvent { - let source = rx_delegate.observe("tableView:didDeselectRowAtIndexPath:") + let source = rx_delegate.observe(#selector(UITableViewDelegate.tableView(_:didDeselectRowAtIndexPath:))) .map { a in return a[1] as! NSIndexPath } @@ -159,7 +159,7 @@ extension UITableView { Reactive wrapper for `delegate` message `tableView:accessoryButtonTappedForRowWithIndexPath:`. */ public var rx_itemAccessoryButtonTapped: ControlEvent { - let source: Observable = rx_delegate.observe("tableView:accessoryButtonTappedForRowWithIndexPath:") + let source: Observable = rx_delegate.observe(#selector(UITableViewDelegate.tableView(_:accessoryButtonTappedForRowWithIndexPath:))) .map { a in return a[1] as! NSIndexPath } @@ -171,7 +171,7 @@ extension UITableView { Reactive wrapper for `delegate` message `tableView:commitEditingStyle:forRowAtIndexPath:`. */ public var rx_itemInserted: ControlEvent { - let source = rx_dataSource.observe("tableView:commitEditingStyle:forRowAtIndexPath:") + let source = rx_dataSource.observe(#selector(UITableViewDataSource.tableView(_:commitEditingStyle:forRowAtIndexPath:))) .filter { a in return UITableViewCellEditingStyle(rawValue: (a[1] as! NSNumber).integerValue) == .Insert } @@ -186,7 +186,7 @@ extension UITableView { Reactive wrapper for `delegate` message `tableView:commitEditingStyle:forRowAtIndexPath:`. */ public var rx_itemDeleted: ControlEvent { - let source = rx_dataSource.observe("tableView:commitEditingStyle:forRowAtIndexPath:") + let source = rx_dataSource.observe(#selector(UITableViewDataSource.tableView(_:commitEditingStyle:forRowAtIndexPath:))) .filter { a in return UITableViewCellEditingStyle(rawValue: (a[1] as! NSNumber).integerValue) == .Delete } @@ -201,7 +201,7 @@ extension UITableView { Reactive wrapper for `delegate` message `tableView:moveRowAtIndexPath:toIndexPath:`. */ public var rx_itemMoved: ControlEvent { - let source: Observable = rx_dataSource.observe("tableView:moveRowAtIndexPath:toIndexPath:") + let source: Observable = rx_dataSource.observe(#selector(UITableViewDataSource.tableView(_:moveRowAtIndexPath:toIndexPath:))) .map { a in return ((a[1] as! NSIndexPath), (a[2] as! NSIndexPath)) } diff --git a/RxExample/RxExample.xcodeproj/project.pbxproj b/RxExample/RxExample.xcodeproj/project.pbxproj index 8df02dd6..12ff5de5 100644 --- a/RxExample/RxExample.xcodeproj/project.pbxproj +++ b/RxExample/RxExample.xcodeproj/project.pbxproj @@ -917,7 +917,7 @@ C8CC3EB01C95CB5300ABA17E /* RxTextViewDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTextViewDelegateProxy.swift; sourceTree = ""; }; C8CC3EB11C95CB5300ABA17E /* UIActivityIndicatorView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIActivityIndicatorView+Rx.swift"; sourceTree = ""; }; C8CC3EB21C95CB5300ABA17E /* UIApplication+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIApplication+Rx.swift"; sourceTree = ""; }; - C8CC3EB31C95CB5300ABA17E /* UIBarButtonItem+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Rx.swift"; sourceTree = ""; }; + C8CC3EB31C95CB5300ABA17E /* UIBarButtonItem+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Rx.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C8CC3EB41C95CB5300ABA17E /* UIButton+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+Rx.swift"; sourceTree = ""; }; C8CC3EB51C95CB5300ABA17E /* UICollectionView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UICollectionView+Rx.swift"; sourceTree = ""; }; C8CC3EB61C95CB5300ABA17E /* UIControl+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIControl+Rx.swift"; sourceTree = ""; }; diff --git a/RxTests/XCTest+Rx.swift b/RxTests/XCTest+Rx.swift index e96d7afc..87cb9bab 100644 --- a/RxTests/XCTest+Rx.swift +++ b/RxTests/XCTest+Rx.swift @@ -58,7 +58,7 @@ Event is considered equal if: - parameter lhs: first set of events. - parameter lhs: second set of events. */ -public func XCTAssertEqual(lhs: [Event], _ rhs: [Event], file: StaticString = __FILE__, line: UInt = __LINE__) { +public func XCTAssertEqual(lhs: [Event], _ rhs: [Event], file: StaticString = #file, line: UInt = #line) { let leftEquatable = lhs.map { AnyEquatable(target: $0, comparer: ==) } let rightEquatable = rhs.map { AnyEquatable(target: $0, comparer: ==) } #if os(Linux) @@ -86,7 +86,7 @@ Event is considered equal if: - parameter lhs: first set of events. - parameter lhs: second set of events. */ -public func XCTAssertEqual(lhs: [Recorded>], _ rhs: [Recorded>], file: StaticString = __FILE__, line: UInt = __LINE__) { +public func XCTAssertEqual(lhs: [Recorded>], _ rhs: [Recorded>], file: StaticString = #file, line: UInt = #line) { let leftEquatable = lhs.map { AnyEquatable(target: $0, comparer: ==) } let rightEquatable = rhs.map { AnyEquatable(target: $0, comparer: ==) } #if os(Linux) From c234adb9d762158e6e2007b0ed1e83644e35cacf Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Tue, 22 Mar 2016 11:44:46 +0100 Subject: [PATCH 17/17] Fixes compilation problems with 9.3 runtime. --- .../CollectionViewSectionedDataSource.swift | 2 ++ .../DataSources/TableViewSectionedDataSource.swift | 2 ++ scripts/common.sh | 10 +--------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift index ee35fbac..c2e09b63 100644 --- a/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/CollectionViewSectionedDataSource.swift @@ -8,7 +8,9 @@ import Foundation import UIKit +#if !RX_NO_MODULE import RxCocoa +#endif public class _CollectionViewSectionedDataSource : NSObject diff --git a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift index 1723f559..ba517104 100644 --- a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift @@ -8,7 +8,9 @@ import Foundation import UIKit +#if !RX_NO_MODULE import RxCocoa +#endif // objc monkey business public class _TableViewSectionedDataSource diff --git a/scripts/common.sh b/scripts/common.sh index bebf77d0..e951a1e7 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -23,7 +23,7 @@ BOLDWHITE="\033[1m\033[37m" DEFAULT_IOS7_SIMULATOR=RxSwiftTest/iPhone-4s/iOS/7.1 DEFAULT_IOS8_SIMULATOR=RxSwiftTest/iPhone-6/iOS/8.4 -DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.2 +DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.3 DEFAULT_WATCHOS2_SIMULATOR=RxSwiftTest/Apple-Watch-38mm/watchOS/2.1 DEFAULT_TVOS_SIMULATOR=RxSwiftTest/Apple-TV-1080p/tvOS/9.1 @@ -90,14 +90,6 @@ function ensure_simulator_available() { xcrun simctl create "${SIMULATOR}" "com.apple.CoreSimulator.SimDeviceType.${DEVICE}" "${RUNTIME}" } -if runtime_available "com.apple.CoreSimulator.SimRuntime.iOS-9-2"; then - DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.2 -elif runtime_available "com.apple.CoreSimulator.SimRuntime.iOS-9-1"; then - DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.1 -else - DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.0 -fi - BUILD_DIRECTORY=build function rx() {