Creating a Universal iOS App Tutorial
Just when I thought I had a somewhat decent grasp on developing and deploying iOS apps Apple came out with the iPad and threw a whole new element in the mix when it comes to developing. Thankfully, the iPad will allow iPhone apps to run on the device, but the user experience is definitely sub-par. So what is the best approach to providing an native iPhone app and a native iPad app? The first option is to duplicate your existing iPhone app code base and modify all your views and some of the controllers to take advantage of the features in the 3.2 SDK. The problem with that is the massive DUPLICATION of code and to be honest it seems quite lazy. I have seen lots of examples where developers use the idiom check for which device is being used, as well as, runtime checks for selectors in order to leverage the correct methods/classes for the given device. While this is certainly a better approach then having two separate code bases with 90% of the same code you now have code that is sprinkled/littered with if/else checks. Unfortunately, you are once again stuck with code that will be maintainable for long. After reading the chapter on universal apps from the upcoming book from Pragmatic Programmers, iPad Programming, I found a much better design pattern of splitting out the app into Shared, iPhone and iPad resources, classes and delegates.
- Compiled for 3.2 and 4.0
- Utilizes navigation controller based app for iPhone device and SplitViewController for iPad
- Shared "model" class and controller classes
- Separate resources (classes/xibs) for the different devices

Comments [0]