I have the following code example (from PlayGround):
class Serializable : NSObject{ override init() { } } class Device : Serializable{ var uuid:String override init() { println("init ") self.uuid = "XXX" self.uuid = Device.createUUID() println(self.uuid) } class func createUUID() -> String{ return "XXX2" } } var device = Device()
You may notice that I applied the createUUID method as static.
But why can't I call this method from init non-static ?:
class Serializable : NSObject{ override init() { } } class Device : Serializable{ var uuid:String override init() {
Without inheritance, it works correctly:
class Device { var uuid:String init() { println("init ") self.uuid = "XXX" self.uuid = self.createUUID() println(self.uuid) } func createUUID() -> String{ return "XXX2" } } var device = Device()
source share