ios - How to cast controller to a specific protocol instead of a class in Swift? -
this protocol:
protocol dbviewanimationtransitioning { var viewforanimation: uiview? { set } } example of usage inside prepareforsegue::
override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if let controller = segue.destinationviewcontroller as? dbviewanimationtransitioning { controller.viewforanimation = sender as? uiview //cannot assign to viewforanimation in controller } } everything fine when cast specific controller f.e. dbfindviewcontroller. need cast specific protocol not class. how accomplish this?
because protocol isn't class/struct cannot assign because may struct make no sense because copied. try making class protocol declaring protocol dbviewanimationtransitioning : class
Comments
Post a Comment