iphone - iOS并发/版本分发

标签 iphone ios multithreading concurrency grand-central-dispatch

我有一个问题,但是可能可以通过几个相关问题之一来回答。

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

我对iOS设备版本的发布感到好奇。 Google在此处发布有关每个版本的手机数量的数据:

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

我还没有从Apple找到任何类似的东西(是的,他们会发布的)。我还能在其他地方找到有关iOS的类似信息吗?

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

同样,有关手头实际问题的任何建议也将不胜感激。

最佳答案

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

苹果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];
    }
}

关于iphone - iOS并发/版本分发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8965094/

相关文章:

ios - 读取和写入 plist(iPhone 编程)

ios - Delphi XE8 Firemonkey iOS 应用程序仅使用 TEdit 就崩溃

iOS:Siri 不可用不返回 AVAudioSessionInterruptionOptionShouldResume

c++ - OpenMP:嵌套并行化有什么好处?

multithreading - 关于 Goroutines 的 Golang 内存泄漏

multithreading - 在 Grails 服务中管理线程

iphone - iPhone 关机时是否可以引发事件?

iphone - HTTP带用户名密码认证和XML解析iPhone

iphone - 从 iPhone 中的服务器检索后 Unicode 字符更改

javascript - 网页是否有可能检测到它是从 webview 应用程序访问的?