Skip to content

Commit f402256

Browse files
committed
Moves location manager and UIImagePickerViewController extensions from RxCocoa to RxExample project. ReactiveX#874
1 parent ac15640 commit f402256

File tree

9 files changed

+94
-37
lines changed

9 files changed

+94
-37
lines changed

Rx.xcodeproj/project.pbxproj

Lines changed: 0 additions & 28 deletions
Large diffs are not rendered by default.

RxCocoa/Common/CLLocationManager+Rx.swift renamed to RxExample/Extensions/CLLocationManager+Rx.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import CoreLocation
1010
#if !RX_NO_MODULE
11-
import RxSwift
11+
import RxSwift
12+
import RxCocoa
1213
#endif
1314

14-
1515
extension CLLocationManager {
1616

1717
/**
@@ -216,3 +216,24 @@ extension CLLocationManager {
216216

217217

218218
}
219+
220+
221+
private func castOrThrow<T>(resultType: T.Type, _ object: AnyObject) throws -> T {
222+
guard let returnValue = object as? T else {
223+
throw RxCocoaError.CastingError(object: object, targetType: resultType)
224+
}
225+
226+
return returnValue
227+
}
228+
229+
private func castOptionalOrThrow<T>(resultType: T.Type, _ object: AnyObject) throws -> T? {
230+
if NSNull().isEqual(object) {
231+
return nil
232+
}
233+
234+
guard let returnValue = object as? T else {
235+
throw RxCocoaError.CastingError(object: object, targetType: resultType)
236+
}
237+
238+
return returnValue
239+
}

RxCocoa/Common/Proxies/RxCLLocationManagerDelegateProxy.swift renamed to RxExample/Extensions/RxCLLocationManagerDelegateProxy.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
import CoreLocation
1010
#if !RX_NO_MODULE
11-
import RxSwift
11+
import RxSwift
12+
import RxCocoa
1213
#endif
1314

1415
class RxCLLocationManagerDelegateProxy : DelegateProxy
1516
, CLLocationManagerDelegate
1617
, DelegateProxyType {
17-
1818
class func currentDelegateFor(object: AnyObject) -> AnyObject? {
19-
let locationManager: CLLocationManager = castOrFatalError(object)
19+
let locationManager: CLLocationManager = object as! CLLocationManager
2020
return locationManager.delegate
2121
}
2222

2323
class func setCurrentDelegate(delegate: AnyObject?, toObject object: AnyObject) {
24-
let locationManager: CLLocationManager = castOrFatalError(object)
25-
locationManager.delegate = castOptionalOrFatalError(delegate)
24+
let locationManager: CLLocationManager = object as! CLLocationManager
25+
locationManager.delegate = delegate as? CLLocationManagerDelegate
2626
}
2727
}

RxCocoa/iOS/UIImagePickerController+Rx.swift renamed to RxExample/Extensions/UIImagePickerController+Rx.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Foundation
1313

1414
#if !RX_NO_MODULE
1515
import RxSwift
16+
import RxCocoa
1617
#endif
1718
import UIKit
1819

@@ -50,3 +51,11 @@ import Foundation
5051
}
5152

5253
#endif
54+
55+
private func castOrThrow<T>(resultType: T.Type, _ object: AnyObject) throws -> T {
56+
guard let returnValue = object as? T else {
57+
throw RxCocoaError.CastingError(object: object, targetType: resultType)
58+
}
59+
60+
return returnValue
61+
}

RxExample/RxDataSources/DataSources/Changeset.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
import Foundation
10-
import CoreData
1110
#if !RX_NO_MODULE
1211
import RxSwift
1312
import RxCocoa

Tests/RxCocoaTests/CLLocationManager+RxTests.swift renamed to RxExample/RxExample-iOSTests/CLLocationManager+RxTests.swift

File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// RxTest.swift
3+
// RxExample
4+
//
5+
// Created by Krunoslav Zaher on 9/11/16.
6+
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import XCTest
11+
12+
class RxTest : XCTestCase {
13+
14+
}
15+
16+
let testError = NSError(domain: "dummyError", code: -232, userInfo: nil)
17+
let testError1 = NSError(domain: "dummyError1", code: -233, userInfo: nil)
18+
let testError2 = NSError(domain: "dummyError2", code: -234, userInfo: nil)

Tests/RxCocoaTests/UIImagePickerController+RxTests.swift renamed to RxExample/RxExample-iOSTests/UIImagePickerController+RxTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import RxSwift
1515
import RxCocoa
1616
import XCTest
1717
import UIKit
18-
18+
1919
class UIImagePickerControllerTests: RxTest {
2020

2121
}

RxExample/RxExample.xcodeproj/project.pbxproj

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@
9696
C88BB8C71B07E6C90064D411 /* Dependencies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07E3C2321B03605B0010338D /* Dependencies.swift */; };
9797
C88BB8CA1B07E6C90064D411 /* WikipediaAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = C86E2F3B1AE5A0CA00C31024 /* WikipediaAPI.swift */; };
9898
C88BB8CC1B07E6C90064D411 /* WikipediaPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C86E2F3C1AE5A0CA00C31024 /* WikipediaPage.swift */; };
99+
C88CB6FF1D8F10830021D83F /* CLLocationManager+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB6FC1D8F10830021D83F /* CLLocationManager+Rx.swift */; };
100+
C88CB7001D8F10830021D83F /* RxCLLocationManagerDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB6FD1D8F10830021D83F /* RxCLLocationManagerDelegateProxy.swift */; };
101+
C88CB7011D8F10830021D83F /* UIImagePickerController+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB6FE1D8F10830021D83F /* UIImagePickerController+Rx.swift */; };
102+
C88CB7191D8F109A0021D83F /* CLLocationManager+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB7161D8F109A0021D83F /* CLLocationManager+RxTests.swift */; };
103+
C88CB71A1D8F109A0021D83F /* RxTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB7171D8F109A0021D83F /* RxTest.swift */; };
104+
C88CB71B1D8F109A0021D83F /* UIImagePickerController+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB7181D8F109A0021D83F /* UIImagePickerController+RxTests.swift */; };
105+
C88CB71C1D8F11DB0021D83F /* CLLocationManager+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB6FC1D8F10830021D83F /* CLLocationManager+Rx.swift */; };
106+
C88CB71D1D8F11DB0021D83F /* RxCLLocationManagerDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB6FD1D8F10830021D83F /* RxCLLocationManagerDelegateProxy.swift */; };
107+
C88CB71E1D8F11DB0021D83F /* UIImagePickerController+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88CB6FE1D8F10830021D83F /* UIImagePickerController+Rx.swift */; };
99108
C890A65D1AEC084100AFF7E6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C890A65C1AEC084100AFF7E6 /* ViewController.swift */; };
100109
C89634081B95BE50002AE38C /* RxBlocking.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C8A468EF1B8A8BD000BF917B /* RxBlocking.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
101110
C89634091B95BE50002AE38C /* RxCocoa.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C8A468ED1B8A8BCC00BF917B /* RxCocoa.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -386,6 +395,12 @@
386395
C86E2F3C1AE5A0CA00C31024 /* WikipediaPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = WikipediaPage.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
387396
C86E2F3D1AE5A0CA00C31024 /* WikipediaSearchResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = WikipediaSearchResult.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
388397
C88BB8DC1B07E6C90064D411 /* RxExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RxExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
398+
C88CB6FC1D8F10830021D83F /* CLLocationManager+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CLLocationManager+Rx.swift"; sourceTree = "<group>"; };
399+
C88CB6FD1D8F10830021D83F /* RxCLLocationManagerDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxCLLocationManagerDelegateProxy.swift; sourceTree = "<group>"; };
400+
C88CB6FE1D8F10830021D83F /* UIImagePickerController+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImagePickerController+Rx.swift"; sourceTree = "<group>"; };
401+
C88CB7161D8F109A0021D83F /* CLLocationManager+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CLLocationManager+RxTests.swift"; sourceTree = "<group>"; };
402+
C88CB7171D8F109A0021D83F /* RxTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTest.swift; sourceTree = "<group>"; };
403+
C88CB7181D8F109A0021D83F /* UIImagePickerController+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImagePickerController+RxTests.swift"; sourceTree = "<group>"; };
389404
C890A65C1AEC084100AFF7E6 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
390405
C8984CCE1C36BC3E001E4272 /* NumberCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberCell.swift; sourceTree = "<group>"; };
391406
C8984CCF1C36BC3E001E4272 /* NumberSectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberSectionView.swift; sourceTree = "<group>"; };
@@ -545,6 +560,7 @@
545560
C8A468EF1B8A8BD000BF917B /* RxBlocking.framework */,
546561
C8A468ED1B8A8BCC00BF917B /* RxCocoa.framework */,
547562
C8A468EB1B8A8BC900BF917B /* RxSwift.framework */,
563+
C88CB6FB1D8F10830021D83F /* Extensions */,
548564
C8B290A51C959D2900E923D0 /* RxDataSources */,
549565
C83366DF1AD0293800C668A7 /* RxExample */,
550566
C849EF621C3190360048AC4A /* RxExample-iOSTests */,
@@ -660,6 +676,9 @@
660676
C849EF621C3190360048AC4A /* RxExample-iOSTests */ = {
661677
isa = PBXGroup;
662678
children = (
679+
C88CB7161D8F109A0021D83F /* CLLocationManager+RxTests.swift */,
680+
C88CB7171D8F109A0021D83F /* RxTest.swift */,
681+
C88CB7181D8F109A0021D83F /* UIImagePickerController+RxTests.swift */,
663682
C89C2BD71C32231A00EBC99C /* Mocks */,
664683
C849EF631C3190360048AC4A /* RxExample_iOSTests.swift */,
665684
C89C2BD51C321DA200EBC99C /* TestScheduler+MarbleTests.swift */,
@@ -773,6 +792,16 @@
773792
path = GitHubSignup;
774793
sourceTree = "<group>";
775794
};
795+
C88CB6FB1D8F10830021D83F /* Extensions */ = {
796+
isa = PBXGroup;
797+
children = (
798+
C88CB6FC1D8F10830021D83F /* CLLocationManager+Rx.swift */,
799+
C88CB6FD1D8F10830021D83F /* RxCLLocationManagerDelegateProxy.swift */,
800+
C88CB6FE1D8F10830021D83F /* UIImagePickerController+Rx.swift */,
801+
);
802+
path = Extensions;
803+
sourceTree = "<group>";
804+
};
776805
C8984CCD1C36BC3E001E4272 /* TableViewPartialUpdates */ = {
777806
isa = PBXGroup;
778807
children = (
@@ -1152,12 +1181,14 @@
11521181
C822B1E31C14E4810088A01A /* SimpleTableViewExampleViewController.swift in Sources */,
11531182
C8477FF81D29DE8C0074454A /* FloatingPointType+IdentifiableType.swift in Sources */,
11541183
C8C46DAC1B47F7110020D71E /* WikipediaSearchViewController.swift in Sources */,
1184+
C88CB6FF1D8F10830021D83F /* CLLocationManager+Rx.swift in Sources */,
11551185
07A5C3DB1B70B703001EFE5C /* CalculatorViewController.swift in Sources */,
11561186
C849EF861C3195180048AC4A /* GitHubSignupViewController2.swift in Sources */,
11571187
C8477FF11D29DE8C0074454A /* AnimatableSectionModelType.swift in Sources */,
11581188
C8F8C49D1C277F4F0047640B /* CalculatorAction.swift in Sources */,
11591189
C864BAD71C3332F10083833C /* DetailViewController.swift in Sources */,
11601190
C822B1DF1C14CEAA0088A01A /* BindingExtensions.swift in Sources */,
1191+
C88CB7011D8F10830021D83F /* UIImagePickerController+Rx.swift in Sources */,
11611192
C864BAD91C3332F10083833C /* RandomUserAPI.swift in Sources */,
11621193
C8477FF01D29DE8C0074454A /* AnimatableSectionModelType+ItemPath.swift in Sources */,
11631194
C864BADF1C3332F10083833C /* UIImageView+Extensions.swift in Sources */,
@@ -1192,6 +1223,7 @@
11921223
C83367231AD029AE00C668A7 /* Example.swift in Sources */,
11931224
C890A65D1AEC084100AFF7E6 /* ViewController.swift in Sources */,
11941225
C8477FFB1D29DE8C0074454A /* IntegerType+IdentifiableType.swift in Sources */,
1226+
C88CB7001D8F10830021D83F /* RxCLLocationManagerDelegateProxy.swift in Sources */,
11951227
C8C46DAA1B47F7110020D71E /* WikipediaSearchCell.swift in Sources */,
11961228
B1604CB51BE49F8D002E1279 /* DownloadableImage.swift in Sources */,
11971229
C8477FF51D29DE8C0074454A /* CollectionViewSectionedDataSource.swift in Sources */,
@@ -1217,15 +1249,21 @@
12171249
isa = PBXSourcesBuildPhase;
12181250
buildActionMask = 2147483647;
12191251
files = (
1252+
C88CB71C1D8F11DB0021D83F /* CLLocationManager+Rx.swift in Sources */,
12201253
C89C2BD61C321DA200EBC99C /* TestScheduler+MarbleTests.swift in Sources */,
12211254
C849EF901C319E9A0048AC4A /* GithubSignupViewModel1.swift in Sources */,
12221255
C849EF641C3190360048AC4A /* RxExample_iOSTests.swift in Sources */,
1256+
C88CB7191D8F109A0021D83F /* CLLocationManager+RxTests.swift in Sources */,
1257+
C88CB71E1D8F11DB0021D83F /* UIImagePickerController+Rx.swift in Sources */,
1258+
C88CB71A1D8F109A0021D83F /* RxTest.swift in Sources */,
12231259
C849EF921C319E9A0048AC4A /* DefaultImplementations.swift in Sources */,
12241260
C849EF991C31A63C0048AC4A /* Wireframe.swift in Sources */,
12251261
C89C2BDC1C32231A00EBC99C /* MockGitHubAPI.swift in Sources */,
12261262
C89C2BDE1C32231A00EBC99C /* NotImplementedStubs.swift in Sources */,
12271263
C849EF9A1C31A7680048AC4A /* ActivityIndicator.swift in Sources */,
12281264
C849EF951C319E9D0048AC4A /* GithubSignupViewModel2.swift in Sources */,
1265+
C88CB71B1D8F109A0021D83F /* UIImagePickerController+RxTests.swift in Sources */,
1266+
C88CB71D1D8F11DB0021D83F /* RxCLLocationManagerDelegateProxy.swift in Sources */,
12291267
C89C2BDD1C32231A00EBC99C /* MockWireframe.swift in Sources */,
12301268
C89C2BDF1C32231A00EBC99C /* ValidationResult+Equatable.swift in Sources */,
12311269
C849EF911C319E9A0048AC4A /* Protocols.swift in Sources */,

0 commit comments

Comments
 (0)