Code Block class One { func sayOne() { print("from inside One") } class Second { func saySecond() { print("from inside second") } } } One.Second().saySecond()
Why can I access Second class without instantiating One() with parenthesis, when I can't access member function and variables without instantiation with ()?
You have defined Second inside One.
So, when you call One.Second(), you just create an instance of Second ("prefixed" by One). You don't have to create an instance of One.
You do the same when you call from a framework:
which is equivalent to
One just tells that we look for Second() inside this class.
So, when you call One.Second(), you just create an instance of Second ("prefixed" by One). You don't have to create an instance of One.
You do the same when you call from a framework:
Code Block let vc = UIKit.UIViewController()
which is equivalent to
Code Block let vc2 = UIViewController()
One just tells that we look for Second() inside this class.