4
votes

I noticed that when I create a new project in XCode for a Universal iPad/iPhone application, the template comes with two separate App Delegate files, one for each device. I can't seem to locate the place in code where it tries to decide which app delegate to use.

I have an existing iPhone project I'd like to port to iPad. My thinking was that if I went ahead and designed the iPad project, I could just import my iPhone classes and nibs, and then use the App Delegate and UIDevice to decide which MainWindow.xib to load. The process went like this:

  1. Create an iPad project coded as a split-view
  2. create brand new classes and nibs for the iPad
  3. import iPhone classes and nibs
  4. Change build/target settings in accordance with Universal Apps
  5. Use [[UIDevice currentDevice] model] in the AppDelegate to decide which MainWindow to load

Will this work, or does the app just automatically know which device it's being deployed on?

Thanks for any insight you can offer.

2

2 Answers

5
votes

The decision which NIB file to load is made in the Info.plist (Main nib file base name vs. Main nib file base name (iPad)). The class of the App Delegate is then set in the respective NIB files themselves.

2
votes

The latest version of the SDK has a menu command to transition you project to being universal. Don't do it by hand! It won't do all the work for you, but basically sets up the templates as if you were just starting off with a universal app and allows you to code more, move files less.