ios - How to override mutable property from a superclass -
class arcanecardvc: uiviewcontroller { var currentcard: arcanecardview? } class postvc: arcanecardvc { override var currentcard: postcard? // <===== want cant } class arcanecardview: uiview { } class postcard: arcanecardview { }
here error get:
cannot override mutable property 'currentcard' of type 'arcanecardview?' covariant type 'postcard?'
the other solution explicitly doing in code everytime use currentcard:
var card = currentcard as! postcard
the correct way way you're doing currentcard as! postcard
.
another option use property getter like
// inside postvc // note camel case on 'c' makes different variable super class var currentcard: postcard { { return self.currentcard as! postcard } }
then you'd use self.currentcard
instead of self.currentcard as! postcard
Comments
Post a Comment