So what does App actually refer to? If you change your app class name why does App. still refer to the right method that you wrote on your class called "TestApp"?
This is a long standing area of confusion. When the runtime starts your program, it creates 1 instance of your app class. But, at runtime how do you access that instance? You can't use TestApp as that's the name of the class and not a reference to the one instance. So how do you, the end user, get access to this one instance?
When the IDE compiles your program it actually inserts a function called App that, if you wrote it, would look something like:
Function App() As TestApp
return mAppSingleton
When the runtime starts, it creates an instance of your app class and saves that reference so it can return it later when needed.
So the App function always returns an instance of your app class - regardless of what it's called.
And you can always use App.whatever to refer to methods, properties, constants etc. that you put on your app class.
No comments:
Post a Comment