Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to conditionally include code only if above certain iOS version? [duplicate]

I have a piece of code that only works on iOS 6 or greater.

control.tintColor = [UIColor greenColor];

Is there a ready to use compiler directive like #ifdef iOS6_or_greater?

like image 417
openfrog Avatar asked Sep 02 '13 11:09

openfrog


1 Answers

It's best if you check against the functionality, instead of the iOS version.

For example you can use respondsToSelector to see if a given method is supported.

[someObject respondsToSelector:@selector(someMethod)]

Failing that, there is a preprocessor directive

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
- (BOOL)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
#endif
like image 182
Andrew Avatar answered Oct 18 '22 21:10

Andrew