Lets say we are extending a parent class A as
extension A {
struct S {
var x = ""
}
}
and we have another class that inherits class A e.g.
class B: A {
}
As struct/enum are static members we can only call the struct S using class name A as:
A.S().x
I want to know if somehow it can be possible through some function we can call the variables inside struct using instance of class B. So e.g.
var c = B()
and i need the struct to be accessible via instance of class B like:
c.S().x
So can we write some function in class A which can return all the contents of struct S ? something like :
extension A {
struct S {
var x = ""
}
func getS() {
// return all members of S (not just x, there can be multiple variables)
}
}
so in the end I should be able to access S using: c.getS().x
Sis not a static member, is an inner class, which it tied to the concrete typeA.