16.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{BOOLresult=NO;if([[UIDevicecurrentDevice]respondsToSelector:@selector(isMultitaskingSupported)]){result=[[UIDevicecurrentDevice]isMultitaskingSupported];}returnresult;}-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{if([selfisMultitaskingSupported]){NSLog(@"Multitasking is supported.");}else{NSLog(@"Multitasking is not supported.");}self.window=[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];self.window.backgroundColor=[UIColorwhiteColor];[self.windowmakeKeyAndVisible];returnYES;}
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, you may be developing your app using the latest iOS SDK but set the target iOS version (the minimum version of iOS on which your app can run) to one version lower than the latest SDK version. In this case, an older device with that OS version can still run your app, but that device may not support multitasking. The golden rule in software development or even in life (not trying to be philosophical) is that if you make an assumption, you’ll eventually be wrong. So never make an ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access