1

I have one question but it can probably be answered by one of several related questions.

I'm developing a simple card game on iOS that requires me to run some AI and game logic concurrently with the main UI thread. I want my application to be compatible with as many devices as possible but I understand there is no need to target platforms with very little actual market share. I will probably avoid using Grand Central Dispatch as it requires iOS 4.0 or greater. The OSX Developer Library lists NSOperation as available since OSX 10.5 and that came out in 2007 a few months after iOS v1 (I'll just assume it works on iOS for now). NSThread is supported I'm sure.

I am curious about the distribution of device versions for iOS. Google posts data for the quantity of phones for each version here:

http://developer.android.com/resources/dashboard/platform-versions.html

I haven't found anything similar from Apple (yeah right they'd release that). Is there somewhere else I can find similar information about iOS ?

I know that for any given device, NSThread will be undoubtedly compatible. NSOperation will be probably compatible, and GCD maybe. But what should be done in the general case? Like for some other feature I'll want to implement in the future.

Also any advice on the actual problem at hand would be appreciated as well.

xst
  • 2,536
  • 5
  • 29
  • 41
  • 1
    Marco Arment posted some useful stats about iOS version distribution based on users of his app on his blog: http://www.marco.org/2011/11/30/more-ios-device-and-os-version-stats-from-instapaper – jonkroll Jan 22 '12 at 22:31

1 Answers1

3

NSThread and NSOperation are both available in iOS2.0 and later.

This question discusses the idea of cutting off support for old iOS versions in existing apps. And another discusses more on version support.

If you'd like to support old iOS versions but still make use of some features in newer iOS versions, you might need to do two things:

Test for method availability:

//UITableView - backgroundView is available in iOS3.2 and later.
if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) {
    UIImageView *theBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"back.png"]];
    [self.tableView setBackgroundView:theBackgroundView];
    [theBackgroundView release];
} else {
    //on devices running iOS 3.2 and below, the background remains unchanged, default.
}

Weak Linking:

New in iOS SDK 4.2 (not the firmware), for projects compiled against SDK 4.2, you can check for class existence, simply:

if ([UIPrintInteractionController class]) {
    // Create an instance of the class and use it.
} else {
    // The print interaction controller is not available.
}

Apple docs. (search for Weak Linking)

Pre iOS SDK 4.2, you could do this using a string with the name of the class:

Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {          
    // Check whether the current device is configured for sending SMS messages
    if ([messageClass canSendText]) {
        [self displaySMSComposerSheet];
    }
}
Community
  • 1
  • 1
MattyG
  • 8,449
  • 6
  • 44
  • 48