let's have following piece of code:
protocol itemview { var image: uiimage? { set } } class basecontroller<t: uiview t: itemview>: uiviewcontroller { var itemview = t() } class concreteitemcontroller: basecontroller<uiimageview> { }
for basecontroller getting error message saying "type "uiimageview" not conform protocol "itemview"".
but why?
same error message shows when instead:
typealias concreteitemcontroller = basecontroller<uiimageview>
i missing here...why uiimageview not conform itemview protocol? has optional image property..so where's problem?
uiimageview
not declare conforms itemview
. because swift strictly typed language, doesn't infer conformance protocols, types incidentally conform. like:
protocol itemview { var image: uiimage? { set } } class basecontroller<t: uiview t: itemview>: uiviewcontroller { var itemview = t() } extension uiimageview: itemview {} class concreteitemcontroller: basecontroller<uiimageview> { }
Comments
Post a Comment