I’ve noticed in recent versions of Xcode where ARC is used by default, the main.m file Xcode generates for you when you start a new project uses NSStringFromClass([AppDelegate class]) as the parameter for the app delegate in UIApplicationMain instead of just @"AppDelegate" or even just nil
New way:
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
Old way:
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, nil);
return retVal;
}
I’m just wondering if there is a reason for this? It just seems a bit contrived to me, but I’m hoping to be set straight.
It’s a compilation check. It’s better if the argument can be checked at compile-time. If it’s just a string, it’s impossible to check.
Regarding the
nilargument, the documentation says:That supposes you are using a xib file to declare the class of your application delegate. Well, many projects don’t. In general, project templates without xib files (e.g. “Empty Application”) can’t use
nil.