ios - Referencing the class in it self in Class method -


i access class methods inside class self. know use self keyword in class instance so:

class instanceclass {     var testproperty = "testing"      func testmathod() {        print(self.testproperty)     } }  // initiate let newinstance = instanceclass() newinstance.testmathod() // result testing 

what's keyword accessing class in static property in below example:

class baseclass {    static let testproperty = "test"    class func printproperty () {       // here want access testproperty     } } 

i aware baseclass.testproperty in above example want keep abstract.

i have swift 2.11 running.

my bad.. self keyword works class methods also.

example:

class baseclass {     class var testproperty: string {       return "original word"    }      static func printtestpropery() {       print(self.testproperty)    }  }  class childclass: baseclass {   override class var testproperty: string {     return "modified word"   } }   childclass.printtestpropery() // prints "modified word" 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -