Check this GitHub Gist
https://gist.github.com/998472
You can add the code or include it in your ...-Prefix.pch file so you can use it wherever you need it.
EDIT
I'm leaving an example of how you can use the code from Gist so people can check if it's useful for their case. This can also be found over the Gist.
/*
* Usage
*/
if (SYSTEM_VERSION_LESS_THAN(@"4.0")) {
...
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.1.1")) {
...
}