Cannot assign value of type ‘UIKit.UIView’ to type ‘UIKit.UIView’ [closed]

Any help in solving this compilation error.

I have this protocol

protocol PresenterProtocol {
    associatedtype V: UIView
    associatedtype VM
    var view: V? { get set }
    func stateToViewModel(with state: State) -> VM
}

and this class implementing it

class Presenter: PresenterProtocol {
    var view: UIView?
}

then this line

presenter.view = UIView()

produces this compilation error
Cannot assign value of type 'UIKit.UIView' to type 'UIKit.UIView'

  • What is Component? I know UIView is not related to Component as far as I can see. Why did you expect this to work?

    – 

  • Component is a UIView, so if you think this should not work, what r the reasons

    – 

Leave a Comment