Created
January 17, 2023 07:50
-
-
Save lalkrishna/05388a71ccecec7757a16469a7895403 to your computer and use it in GitHub Desktop.
MenuBuilder
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
protocol ViewControllerConvertable { | |
var viewController: UIViewController { get } | |
} | |
struct ViewControllerInstantiator: ViewControllerConvertable { | |
let instantiatableType: Instantiatable.Type // Refer: https://gist.github.com/lalkrishna/3770ce3933feaf4d7c0d3f1323e7fd72 | |
internal init(_ instantiatableType: Instantiatable.Type) { | |
self.instantiatableType = instantiatableType | |
} | |
var viewController: UIViewController { | |
instantiatableType.instantiate() as! UIViewController // swiftlint:disable:this force_cast | |
} | |
} | |
struct ViewControllerInitialized: ViewControllerConvertable { | |
private let `internal`: () -> UIViewController | |
internal init(_ internal: @escaping () -> UIViewController) { | |
self.internal = `internal` | |
} | |
var viewController: UIViewController { | |
`internal`() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment