Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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