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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -