2016-10-02 119 views
0

我是iOS新手。在我們的iOS應用程序中,我需要在iOS版本=> 9中執行function1,在iOS版本中執行function2到<。9.以下代碼是否適用於此場景?iOS在不同版本的代碼中運行代碼

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000 
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 
{ 
    // when the app is opened due to a deep link, call the Tune deep link setter 
    [Tune applicationDidOpenURL:url.absoluteString sourceApplication:sourceApplication]; 

    return YES; 
} 
#endif 

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000 
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options 
{ 
    // when the app is opened due to a deep link, call the Tune deep link setter 
    NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey]; 

    [Tune applicationDidOpenURL:url.absoluteString sourceApplication:sourceApplication]; 

    return YES; 
} 
#endif 

回答

0

請嘗試this link

但改變功能: 「isOperatingSystemAtLeastVersion」 如果有的話。

if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){.majorVersion = 9, .minorVersion = 1, .patchVersion = 0}]) { 
    NSLog(@"Hello from > iOS 9.1"); 
} 

// Using short-form for the struct, we can make things somewhat more compact: 
if ([NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9,3,0}]) { 
    NSLog(@"Hello from > iOS 9.3"); 
}