12.1. Detecting the Availability of Multitasking

Problem

You want to find out whether the iOS device running your application supports multitasking.

Solution

Call the isMultitaskingSupported instance method of UIDevice, like so:

- (BOOL) isMultitaskingSupported{
  
  BOOL result = NO;
  if ([[UIDevice currentDevice] 
       respondsToSelector:@selector(isMultitaskingSupported)]){
    result = [[UIDevice currentDevice] isMultitaskingSupported];
  }
  return result;
  
}

- (BOOL)            application:(UIApplication *)application
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
  
  if ([self isMultitaskingSupported]){
    NSLog(@"Multitasking is supported.");
  } else {
    NSLog(@"Multitasking is not supported.");
  }
  
  self.window = [[UIWindow alloc] initWithFrame:
                 [[UIScreen mainScreen] bounds]];
  
  self.window.backgroundColor = [UIColor whiteColor];
  [self.window makeKeyAndVisible];
  return YES;
}

Discussion

Your application, depending on the iOS devices it targets, can be run and executed on a variety of devices on different versions of iOS. For instance, if you compile your application with iOS SDK 5.0 and your deployment target OS is 4.0, your application can be run on the iPhone 3G, iPhone 3GS, iPhone 4, and iPod touch (second and third generations), provided that the iOS on these devices has been updated to iOS 4.0 or iOS 5. Furthermore, a device could have iOS 5.0 or later installed on it, but the underlying hardware might not be strong enough for multitasking to be supported. Because of this, your application must be aware ...

Get iOS 5 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.