开发者

What will happen if I use some iOS5 features but the deployment target is a iOS4 device?

开发者 https://www.devze.com 2023-04-12 18:57 出处:网络
I am switching my SDK from iOS4 to iOS5, and I want to use some iOS5 features in my old iOS4 projects.

I am switching my SDK from iOS4 to iOS5, and I want to use some iOS5 features in my old iOS4 projects.

What will happ开发者_StackOverflow社区en if I use some iOS5 features but the deployment target is a iOS4 device ?

Thanks.


it will just crash, most propably because of unrecognized selector.

to avoid this, you can fork the code with if()-statements

like

if([object respondsToSelector:@newiOS5Selector])

Also, you can read out the current iOS version via UIDevice

+(BOOL)platformSupportsVersion:(NSString *)requiredVersion
{
    float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (systemVersion >= [requiredVersion floatValue]) {
        return YES;
    } 

    return NO;
}


That features will work only on devices with installed iOS5 or later.

If you will call new iOS5 API on devices with previous versions of iOS (4.x) it will crash in that places.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号