
It basically depends on the complexity of your app and what trade-offs you are willing to accept. For the former ones, you can decide on which class to instantiate them from by using the UI_USER_INTERFACE_IDIOM check.Īlternatively, you could have two different delegate classes, one that creates the iphone UI and the other the ipad UI this is also a perfectly reasonable approach. In your – application:didFinishLaunchingWithOptions: (the app entry point) you should then create your UI, that is creating that set of objects that you would otherwise define in a nib (controllers, views, whatever a nib is just a mechanism to visually "create" and connect objects if you don't do it visually, you do it programmatically) and connecting them now, some of those objects do depend on the device (i.e., views), others not. What I was pointing to is that if you are not providing a nib, you should specify a delegate, which simply defines for your app a high-level entry-point. Likely, the app delegate is a part of the app that does not depend on the device, so you would not strictly need to instantiate one for the iphone and a different one for the ipad. If you do it programmatically, you have to do it where you need it. Note the change in XCode 4.2: return UIApplicationMain(argc, argv, nil, I think so either you do it at xib level, or programmatically.Ģ) Are you suggesting I put the if statement to track the device in xibs, I don't need to specify UI_USER_INTERFACE_IDIOM To the questions you ask in the comments:ġ) If there are. So, I don't see anything bad in it.Īn alternative approach might be using UIDevice itself, or UIDevice-Extension, which is a framework extending UIDevice. Indeed, if you check the definition of that macro you will see it is based on a UIDevice class that returns information about the device where you program runs. and hoping this does not involve checking if UI_USER_INTERFACE_IDIOM() = UIUserInterfaceIdiomPad.ĪFAIK, UI_USER_INTERFACE_IDIOM is the official way to do that.

So, you simply execute: int retVal = UIApplicationMain(argc, argv, nil, ) Īnd you program will use that delegate class instead of the one defined in the nib.Īlso consider editing the ist file, where you should remove all entries about the main nib files you find there, otherwise your program will crash if you remove the xib files from the project.ĮDIT: I realized late that you are also asking about how to differentiate an iPad from an iPhone.

Where UIApplicationMain is defined as: int UIApplicationMain (

Have a look at your main.c file, it should contain a statement like this: int retVal = UIApplicationMain(argc, argv, nil, nil)
