lundi 28 septembre 2020

How to find a class instance name in other class in swift?

Imagine a situation that we have two classes like these:

class MyClass {
    func printInstanceName() {
        print(what?);
    }
}

class User {
    var myObject: MyClass!
}

I will instantiate an object of class User like this:

let user = User();

and call printInstanceName on user like this:

user.myObject.printInstanceName();

How should i implement the printInstanceName that print the name of the MyClass instance in User? (myObject)





Aucun commentaire:

Enregistrer un commentaire