When I start a single view application and instead of assigning the rootViewController
programmatically from AppDelelgate
, try to use the 'Main Interface' option to assign a xib
as my main interface file, a SIGABRT
signal is sent to the program when I run it.
Why does this happen? What is the purpose of the 'Main Interface' option?
I found out how to do this. It was very obvious after I understood the whole process of how the application is loaded. So I thought I'll answer my own question.
The key is to initialize the window and set up the UIApplication
and its delegate from the xib itself.
UIWindow
object in it. Make the file's
owner of the xib as UIApplication
.AppDelegate
object in the xib and connect the
file's owner's delegate
outlet to this object.AppDelegate
class.applicationDidFinishLaunchingWithOptions:
method.If you run the program it will show the window in the simulator, but you'll get a warning that application is supposed to have a rootViewController
at the end of application launch.
applicationDidFinishLaunchingWithOptions:
we can
instantiate a UIViewController
and assign the window outlets
rootViewController as this view controller.