I am trying to create a class method which optionally returns an (already instantiated) instance of the class.
I'm thinking of something like writing the memory address of the instantiated class to a user default key and then trying to return the object at that address but I'm not sure if that's a correct approach or how to do that.
class MyClass {
let myProperty: String
required init(myProperty: String) {
self.myProperty = myProperty
}
class func currentClass() -> MyClass? {
return nil
}
}
let aNewClass = MyClass(myProperty: "Hi")
// Should return the aNewClass instance:
MyClass.currentClass()