by
141 9

UINavigationControllerDelegate + Rx

Rx extension for navigation controller delegate
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/2494118/UINavigationControllerDelegate---Rx?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
class RxNavigationControllerDelegateProxy: DelegateProxy, DelegateProxyType, UINavigationControllerDelegate { static func currentDelegateFor(_ object: AnyObject) -> AnyObject? { guard let navigationController = object as? UINavigationController else { fatalError() } return navigationController.delegate } static func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { guard let navigationController = object as? UINavigationController else { fatalError() } if delegate == nil { navigationController.delegate = nil } else { guard let delegate = delegate as? UINavigationControllerDelegate else { fatalError() } navigationController.delegate = delegate } } } extension Reactive where Base: UINavigationController { /** Reactive wrapper for `delegate`. For more information take a look at `DelegateProxyType` protocol documentation. */ public var delegate: DelegateProxy { return RxNavigationControllerDelegateProxy.proxyForObject(base) } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus