In every iOS app there is an App Delegate class, meaning one of the classes in the app has to implement the delegate methods for the application events such as didFinishLaunching: and so forth. Usually the class name contains “AppDelegate”.
The App Delegate class is a subclass of UIApplicationDelegate on iOS or NSApplicationDelegate on the Mac.
class AppDelegate: UIApplicationDelegate {
}
Let’s say I want to implement the App Delegate methods in a different class than the original one Xcode created and named for me. How can I do that?
You can do the same by modifying the parameters to the
UIApplicationMainfunction present in the main.m file:The last parameter takes the name of the class which is implementing the UIApplicationDelegate protocol.
So the default implementation looks something like:
After modifying it will be something like: