Objective-C has an @available expression in XCode 9+ / LLVM 5+ that allows you to guard a block of code to at least a certain OS version so that it won\'t emit unguarded ava
You do what you always do when you have complex conditional code in the middle of a function that makes the flow complex: you hoist it into another function.
- (void)handleThing {
if (@available(iOS 11.0, *)) {
if (some_condition) {
// code to run when on iOS 11+ and some_condition is true
return;
}
}
// code to run when on older iOS or some_condition is false
}
Or you hoist the check into generic code (see Josh Caswell's; it's better than how I originally wrote this).