override - Overriding default value of instance var -


given class obj,

class obj: nsobject {     var x = "x" } 

and subclass, obj1, how change default value of var x?

simply setting new value make sense, seems error out...

class obj1: obj {     var x = "y" } 

❗️ cannot override stored property 'x'

define init() method as:

init () {   super.init()   x = "y" } 

you'll want other initializers in obj1 invoke self.init(). apple documentation has long discussion on designated initializers , inheritance vis-a-vis initializers.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -