Skip to content

Commit 528f2e3

Browse files
authored
Merge pull request #101 from IntrepidPursuits/ben/swift-3-fixes
Fixes for Swift 3
2 parents 5a2cba9 + 3e2edcc commit 528f2e3

File tree

7 files changed

+66
-27
lines changed

7 files changed

+66
-27
lines changed

Intrepid.podspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Intrepid"
3-
s.version = "0.6.4"
3+
s.version = "0.6.5"
44
s.summary = "Swift Bag"
55
s.description = <<-DESC
66
Collection of extensions and utility classes by and for the developers at Intrepid Pursuits.
@@ -35,7 +35,7 @@ Pod::Spec.new do |s|
3535

3636
s.subspec "Rx" do |rx|
3737
rx.source_files = "SwiftWisdom/Rx/**/**/*.swift"
38-
rx.dependency 'RxSwift', '~> 3.0.0-beta.2'
39-
rx.dependency 'RxCocoa', '~> 3.0.0-beta.2'
38+
rx.dependency 'RxSwift', '~> 3.0'
39+
rx.dependency 'RxCocoa', '~> 3.0'
4040
end
4141
end

Podfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use_frameworks!
66

77
def commonpods
88
pod 'IP-UIKit-Wisdom'
9-
pod 'RxSwift', '~> 3.0.0-beta.2'
10-
pod 'RxCocoa', '~> 3.0.0-beta.2'
9+
pod 'RxSwift', '~> 3.0'
10+
pod 'RxCocoa', '~> 3.0'
1111
end
1212

1313
target 'SwiftWisdom' do

Podfile.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
PODS:
22
- IP-UIKit-Wisdom (0.0.9)
3-
- RxCocoa (3.0.0-beta.2):
4-
- RxSwift (~> 3.0.0-beta.2)
5-
- RxSwift (3.0.0-beta.2)
3+
- RxCocoa (3.0.1):
4+
- RxSwift (~> 3.0)
5+
- RxSwift (3.0.1)
66

77
DEPENDENCIES:
88
- IP-UIKit-Wisdom
9-
- RxCocoa (~> 3.0.0-beta.2)
10-
- RxSwift (~> 3.0.0-beta.2)
9+
- RxCocoa (~> 3.0)
10+
- RxSwift (~> 3.0)
1111

1212
SPEC CHECKSUMS:
1313
IP-UIKit-Wisdom: cd9838571e97427a0c61c05d856eaaca9afd7c1a
14-
RxCocoa: 1dd105d8a4e18034ccd7bd6d136445363ce67c8e
15-
RxSwift: 0ea939d7d97cb70657190ffde8dc2a9b455778fc
14+
RxCocoa: 15a52fc590dcc700cb4a690a633b5c5184ce3a78
15+
RxSwift: af5680055c4ad04480189c52d28385b1029493a6
1616

17-
PODFILE CHECKSUM: 2bfd837187f1f7fb6440b6bf36db8dda31ef7394
17+
PODFILE CHECKSUM: 06dd8b46b0e948c45fae0b822db630434644df71
1818

1919
COCOAPODS: 1.1.1

SwiftWisdom/Core/Downloader/Downloader.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ extension URLSessionTask {
8686
// MARK: Operator Overloads
8787

8888
extension Downloader {
89-
public static func == (lhs: Downloader, rhs: Downloader) -> Bool {
89+
@nonobjc public static func == (lhs: Downloader, rhs: Downloader) -> Bool {
9090
return lhs.id == rhs.id
9191
}
9292

93-
public static func != (lhs: Downloader, rhs: Downloader) -> Bool {
93+
@nonobjc public static func != (lhs: Downloader, rhs: Downloader) -> Bool {
9494
return !(lhs == rhs)
9595
}
9696
}

SwiftWisdom/Core/Foundation/Time/NSDate+Comparable.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import Foundation
1010
// Date already conforms to comparable. But NSDate does not.
1111

1212
extension NSDate : Comparable {
13-
public static func < (lhs: NSDate, rhs: NSDate) -> Bool {
13+
@nonobjc public static func < (lhs: NSDate, rhs: NSDate) -> Bool {
1414
return lhs.timeIntervalSince1970 < rhs.timeIntervalSince1970
1515
}
16-
public static func <= (lhs: NSDate, rhs: NSDate) -> Bool {
16+
@nonobjc public static func <= (lhs: NSDate, rhs: NSDate) -> Bool {
1717
return lhs.timeIntervalSince1970 <= rhs.timeIntervalSince1970
1818
}
19-
public static func >= (lhs: NSDate, rhs: NSDate) -> Bool {
19+
@nonobjc public static func >= (lhs: NSDate, rhs: NSDate) -> Bool {
2020
return lhs.timeIntervalSince1970 >= rhs.timeIntervalSince1970
2121
}
22-
public static func > (lhs: NSDate, rhs: NSDate) -> Bool {
22+
@nonobjc public static func > (lhs: NSDate, rhs: NSDate) -> Bool {
2323
return lhs.timeIntervalSince1970 > rhs.timeIntervalSince1970
2424
}
2525
}

SwiftWisdom/Rx/Rx+Extensions.swift

+10-8
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ infix operator <-> : Binding
2323
infix operator <- : Binding
2424
infix operator >>> : Disposing
2525

26-
public func <- <T>(property: AnyObserver<T>, variable: Observable<T>) -> Disposable {
27-
return variable
28-
.observeOn(MainScheduler.instance)
29-
.bindTo(property)
26+
public func <- <T: ObserverType, O: ObservableType>(observer: T, observable: O) -> Disposable where T.E == O.E {
27+
return observable.observeOn(MainScheduler.instance).bindTo(observer)
28+
}
29+
30+
public func <- <T: ObserverType, O>(observer: T, variable: Variable<O>) -> Disposable where T.E == O {
31+
return observer <- variable.asObservable()
3032
}
3133

32-
public func <- <T>(property: AnyObserver<T>, variable: Variable<T>) -> Disposable {
33-
return property <- variable.asObservable()
34+
public func <- <T, O: ObservableType>(variable: Variable<T>, observable: O) -> Disposable where O.E == T {
35+
return observable.bindTo(variable)
3436
}
3537

36-
public func <- <T>(variable: Variable<T>, property: ControlProperty<T>) -> Disposable {
37-
return property.bindTo(variable)
38+
public func <- <T>(observer: Variable<T>, observable: Variable<T>) -> Disposable {
39+
return observer <- observable.asObservable()
3840
}
3941

4042
public func >>> (disposable: Disposable, disposeBag: DisposeBag) {

SwiftWisdomTests/Rx/Rx+ExtensionsTest.swift

+37
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,43 @@ import RxCocoa
66

77
class OperatorTests: XCTestCase {
88

9+
func testVariableBinding() {
10+
let disposeBag = DisposeBag()
11+
let label = UILabel()
12+
let variable = Variable<String?>(nil)
13+
14+
label.rx.text <- variable >>> disposeBag
15+
XCTAssertEqual(nil, label.text)
16+
17+
variable.value = "hello"
18+
XCTAssertEqual("hello", label.text)
19+
20+
variable.value = nil
21+
XCTAssertEqual(nil, label.text)
22+
}
23+
24+
func testObserverBinding() {
25+
let disposeBag = DisposeBag()
26+
let button = UIButton()
27+
let observable = Observable<String?>.just("hello")
28+
XCTAssertEqual(nil, button.title(for: .normal))
29+
button.rx.title(for: .normal) <- observable >>> disposeBag
30+
XCTAssertEqual("hello", button.title(for: .normal))
31+
}
32+
33+
func testBindingToVariable() {
34+
let disposeBag = DisposeBag()
35+
let sut = Variable<String>("")
36+
let variable = Variable<String>("hello")
37+
38+
sut <- variable >>> disposeBag
39+
XCTAssertEqual(variable.value, sut.value)
40+
XCTAssertEqual("hello", sut.value)
41+
42+
variable.value = "world"
43+
XCTAssertEqual(variable.value, sut.value)
44+
}
45+
946
func testAddCompositeDisposable() {
1047
let compositeDisposable = CompositeDisposable()
1148
let observable = Observable<String?>.never()

0 commit comments

Comments
 (0)