Is a MainWindow.xib truly needed in iOS application?

I think the reason why it's now absent is that creating a window programmatically is much more efficient than opening a xib file and unarchiving the objects. Generally, if you can do it in one line of code, you should do that in code.

It is has always been an option not to use MainWindow.xib. The UIWindow could be loaded programmatically by the doing the following:

1) Making sure that the call to UIApplicationMain in main.m looks like this:

UIApplicationMain(argc, argv,nil,@"MyAppDelegateClassName");

rather than this:

UIApplicationMain(argc, argv,nil,nil);

2) Making sure that Info.plist does not have a value of "MainWindow.xib" as the main nib file.

3) Loading the UIWindow programmatically in the app delegate.

So, no, you don't have to use MainWindow.xib and, actually, you never have. You could always do things programmatically.

It is a good question why Apple made this change in the default Xcode settings, and I don't know the answer. But it may have to with performance or the transition to ARC or small application file sizes or something else altogether.

原文地址:https://www.cnblogs.com/StarMud/p/2792544.html