Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:
- The new API will crash if we call it on iOS 7
- The new API won't compile if we build it using the iOS 7 SDK
- The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up
These three problems require three different technical solutions:
- We can avoid calling the new API on an old OS version by using runtime detection (e.g.
respondsToSelector:
) - We can avoid compiling new APIs on old SDKs using the
__IPHONE_OS_VERSION_MAX_ALLOWED
macro