2016-07-26 32 views
0

我已經添加了一些watchOS 3功能到現有的watchOS 2,因爲我必須同時支持WatchOS 2和WatchOS 3設備,所以我需要檢查它之前的功能可用性被調用。例如在ExtensionDelegate中,我有這個功能,只有WatchOS 3設備應該調用它,我如何檢查目標c中的WatchOS版本。檢查功能可用性watchOS 3 Xcode 8與watchOS 2的客觀c

-(void)applicationDidEnterBackground { 

    [self scheduleRefreshBackgroundTask]; 

} 

我已閱讀How to check iOS version?但我仍然困惑如何檢查它在目標c。

+0

鏈接有客觀的版本太多。你還需要什麼 ? –

+0

我需要知道相當於WatchOS 3和目標c - > if #available(iOS 10,*){} – Samira

+0

http://stackoverflow.com/questions/32518548/swift-available-keyword-vs -respondstoselector –

回答

0

我終於發現,通過添加WK_AVAILABLE_WATCHOS_ONLY(3.0)我可以控制watchOS版本,當我需要的watchOS 3的功能添加到現有的watchOS 2項目,並使其兼容:

- (void)applicationDidEnterBackground 
{ 
    [self scheduleRefreshBackgroundTask]; 
} 

- (void)scheduleRefreshBackgroundTask WK_AVAILABLE_WATCHOS_ONLY(3.0) 
{ 
    // do something 
}