1

我有一个问题,但它可以通过几个相关的问题之一来回答。iOS并发/版本分布

我正在iOS上开发一个简单的纸牌游戏,需要我与主UI线程同时运行一些AI和游戏逻辑。我希望我的应用程序能够与尽可能多的设备兼容,但我知道不需要针对实际市场份额很小的平台。我可能会避免使用Grand Central Dispatch,因为它需要iOS 4.0或更高版本。 OSX Developer Library将NSOperation列为自OSX 10.5以来的可用版本,并且在iOS v1之后的几个月(2007年我会假设它现在可在iOS上运行)发布。支持NSThread,我确定。

我很好奇iOS设备版本的分布情况。对于手机在这里每个版本的谷歌量数据发布:

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

我还没有发现任何类似苹果(对,没错,他们会释放)。有什么地方可以找到有关iOS的类似信息吗?

我知道,对于任何给定的设备,NSThread无疑是兼容的。 NSOperation可能会兼容,也可能是GCD。但一般情况下应该怎么做?就像我将来希望实现的其他功能一样。

此外,任何关于实际问题的建议也将受到赞赏。

+1

马科·阿门特发布了关于iOS的版本分布了一些有用的统计数据基础上,用户自己应用在他的博客上:http://www.marco.org/2011/11/30/more-ios-device-and-os-version-stats-from-instapaper – jonkroll

回答

3

NSThreadNSOperation都可以在iOS2.0及更高版本中使用。

question讨论了切断对现有应用程序中旧版iOS的支持的想法。和another讨论更多的版本支持。

如果你想支持老版本的IOS,但仍然使用一些功能在新版iOS版本中,你可能需要做两件事情:

试验方法的可用性:

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

弱链接:

在新的iOS SDK 4.2(不是固件),针对SDK 4.2编译的项目,您可以检查是否存在类,简单地说:

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

Apple docs。 (搜索弱链接)

前的iOS SDK 4.2,你可以这样使用与类名的字符串做:

Class messageClass = (NSClassFromString(@"MFMessageComposeViewController")); 
if (messageClass != nil) {   
    // Check whether the current device is configured for sending SMS messages 
    if ([messageClass canSendText]) { 
     [self displaySMSComposerSheet]; 
    } 
}