Created
December 20, 2021 10:25
-
-
Save jeandavid/0b384f947d4e133943b34075bc0e3ed2 to your computer and use it in GitHub Desktop.
Get the parent view controller by using the UIResponder chain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIResponder { | |
@objc | |
public var parentViewController: UIViewController? { | |
return next as? UIViewController ?? next?.parentViewController | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment