How to change the Application Delegate class?
You can do the same by modifying the parameters to the UIApplicationMain
function present in the main.m file:
UIApplicationMain(argc,argv,nil,nil);
The last parameter takes the name of the class which is implementing the UIApplicationDelegate protocol.
So the default implementation looks something like:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
After modifying it will be something like:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([< Your class name will go here > class]));
[pool release];
return retVal;
I achieved this in Swift by changing the AppDelegate
's default template implementation:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
replace with:
import UIKit
@UIApplicationMain
class MyAppAppDelegate: UIResponder, UIApplicationDelegate {
See the new class name.