O'Reilly logo

iOS 5 Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required