How can I check and conditionally only compile / run code if iOS5 is available ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can either check the
systemVersionproperty ofUIDevicelike so:But personally I don’t like that method as I don’t like the parsing of the string returned from
systemVersionand the comparison done like that.The best way is to check that whatever class / method it is that you want to use, exists. For example:
If you want to use
TWRequestfrom the Twitter framework:Or if you want to use
startMonitoringForRegion:fromCLLocationManagerwhich was brought in in iOS 5.0:In general it’s better to do checks like that than to look at the system version.