Created
April 8, 2021 06:21
-
-
Save vani2/567d6b7dfb28620d9438dae2b15b8ccb to your computer and use it in GitHub Desktop.
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 | |
protocol Presenter: AnyObject { | |
associatedtype T: VCLogic | |
var viewController: T? { get set } | |
} | |
protocol VCLogic: UIViewController { | |
func foo() | |
} | |
class BaseVC: UIViewController, VCLogic { | |
func foo() {} | |
} | |
class OneVC: BaseVC {} | |
class TwoVC: BaseVC {} | |
class OnePresenter: Presenter { | |
typealias T = OneVC | |
var viewController: T? // SIL error | |
} | |
class TwoPresenter: Presenter { | |
typealias T = TwoVC | |
var viewController: T? | |
} | |
class Interactor<T: Presenter> { | |
var presenter: T? | |
} | |
class OneInteractor: Interactor<OnePresenter> {} | |
class TwoInteractor: Interactor<TwoPresenter> {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment