2016-10-02 134 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"); 
}