With Xcode 4 you can develop applications for iPad and iPhone. Also, you can choose a different iOS target. Currently, the last release of iOS is 4.3 and when you will create a new project you will see:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Now, the rootViewController
property has been added with iOS 4. This means that when we going to test the application in iOS 3.2 environment we will get a CRASH! Instead of check the iOS version, we can use a feature of Obejctve-C in order to check if a property exists:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if ([self.window respondsToSelector:@selector(setRootViewController:)]) {
self.window.rootViewController = self.viewController;
} else {
[self.window addSubview:self.viewController.view];
}
[self.window makeKeyAndVisible];
return YES;
}
As usual, please don’t hesitate to leave any questions or comments in the feed below, and I’ll aim to respond to each of them.