I trying to understand the automagic of @UIApplicationMain
and how to visualize the start of an an iOS app in terms of Java:
public class UIApplication extends UIResponder implements Runnable {
final UIApplicationDelegate appDel;
public UIApplication(UIApplicationDelegate appDel) {
this.appDel = appDel;
}
public static void main(String[] args) {
try {
UIApplication app = new UIApplication(new AppDelegate());
handThisReferenceToOperatingSystem(app);
iOSdoesSomethingLikeThis(new Thread(app).start());
} catch(Exception e) { e.printStackTrace(); }
}
public void run() {
// chill-out and wait for iOS to invoke methods in UIResponder class.
// The UIResponder methods invoke my custom methods in AppDelegate.
}
public static class AppDelegate implements UIApplicationDelegate {
public void application(Object UIApplication) { // app specific behaviour
}
public void applicationWillResignActive(Object UIApplication) { // app specific behaviour
}
public void applicationDidEnterBackground(Object UIApplication) { // app specific behaviour
}
public void applicationWillEnterForeground(Object UIApplication) { // app specific behaviour
}
public void applicationDidBecomeActive(Object UIApplication) { // app specific behaviour
}
public void applicationWillTerminate(Object UIApplication) { // app specific behaviour
}
// maybe more methods from the UIApplicationDelegate
}
public interface UIApplicationDelegate {
void application(Object UIApplication);
void applicationWillResignActive(Object UIApplication);
void applicationDidEnterBackground(Object UIApplication);
void applicationWillEnterForeground(Object UIApplication);
void applicationDidBecomeActive(Object UIApplication);
void applicationWillTerminate(Object UIApplication);
// maybe some more methods ....
}
}
public class UIResponder {
void fingerSwipe() { // default implementation
}
void verticalMotion() { // default implementation
}
// more methods iOS might invoke
}
So basically, applying the @UIApplicationMain
attribute to the AppDelegate class makes all the other code go away, right?