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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -