What will happen if I use some iOS5 features but the deployment target is a iOS4 device?
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.
精彩评论