tags:

views:

1571

answers:

2

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.

+5  A: 

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.

Ole Begemann
Thank you. I will get my provisioning profile for the iPad when I get home from work and start
JustinXXVII
+2  A: 

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.

JoePasq
OK, thanks. I basically started fooling around with the SplitView template, got entrenched and kept working with that project. I'll have to start a universal bundle and just import everything from my current project.
JustinXXVII
Also take your original iPhone app and (after making a copy of course) and run the transition command. After that's done you can then start importing/replacing the generated iPad code with the one from your SplitView test project. I did this and you can save a good bit of work vs recoding.
jamone