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