mirror of
https://github.com/ReactiveX/RxSwift.git
synced 2024-10-04 05:57:23 +03:00
Make RxImagePickerDelegateProxy subclass of RXNavigationControllerDelegateProxy
This commit is contained in:
parent
0f4d1ffb78
commit
a5aee86698
@ -14,7 +14,7 @@ import UIKit
|
||||
#endif
|
||||
|
||||
/// For more information take a look at `DelegateProxyType`.
|
||||
public class RxNavigationControllerDelegateProxy
|
||||
open class RxNavigationControllerDelegateProxy
|
||||
: DelegateProxy
|
||||
, UINavigationControllerDelegate
|
||||
, DelegateProxyType {
|
||||
@ -32,7 +32,7 @@ public class RxNavigationControllerDelegateProxy
|
||||
}
|
||||
|
||||
/// For more information take a look at `DelegateProxyType`.
|
||||
public override class func createProxyForObject(_ object: AnyObject) -> AnyObject {
|
||||
open override class func createProxyForObject(_ object: AnyObject) -> AnyObject {
|
||||
let navigationController: UINavigationController = castOrFatalError(object)
|
||||
return navigationController.createRxDelegateProxy()
|
||||
}
|
||||
|
@ -15,49 +15,9 @@
|
||||
import UIKit
|
||||
|
||||
public class RxImagePickerDelegateProxy
|
||||
: DelegateProxy
|
||||
, DelegateProxyType
|
||||
, UIImagePickerControllerDelegate
|
||||
, UINavigationControllerDelegate {
|
||||
: RxNavigationControllerDelegateProxy
|
||||
, UIImagePickerControllerDelegate {
|
||||
|
||||
/**
|
||||
For more information take a look at `DelegateProxyType`.
|
||||
*/
|
||||
public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) {
|
||||
let imagePickerController: UIImagePickerController = castOrFatalError(object)
|
||||
imagePickerController.delegate = castOptionalOrFatalError(delegate)
|
||||
}
|
||||
|
||||
/**
|
||||
For more information take a look at `DelegateProxyType`.
|
||||
*/
|
||||
public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? {
|
||||
let imagePickerController: UIImagePickerController = castOrFatalError(object)
|
||||
return imagePickerController.delegate
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func castOrFatalError<T>(_ value: Any!) -> T {
|
||||
let maybeResult: T? = value as? T
|
||||
guard let result = maybeResult else {
|
||||
rxFatalError("Failure converting from \(value) to \(T.self)")
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private func castOptionalOrFatalError<T>(_ value: AnyObject?) -> T? {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
let v: T = castOrFatalError(value)
|
||||
return v
|
||||
}
|
||||
|
||||
private func rxFatalError(_ lastMessage: String) -> Never {
|
||||
// The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours.
|
||||
fatalError(lastMessage)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -17,15 +17,6 @@
|
||||
|
||||
extension Reactive where Base: UIImagePickerController {
|
||||
|
||||
/**
|
||||
Reactive wrapper for `delegate`.
|
||||
|
||||
For more information take a look at `DelegateProxyType` protocol documentation.
|
||||
*/
|
||||
public var delegate: DelegateProxy {
|
||||
return RxImagePickerDelegateProxy.proxyForObject(base)
|
||||
}
|
||||
|
||||
/**
|
||||
Reactive wrapper for `delegate` message.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user