Search code examples
iosobjective-cios8ios9sfsafariviewcontroller

Implementing iOS9+ protocol on iOS8


I am using SFSafariViewController and SFSafariViewControllerDelegate. The app supports iOS8 too, but this class and delegate is only available from iOS9.

On iOS8 this class and the delegate is not used (SFSafariViewController's availability is checked at runtime, and an iOS8 compatible class is used instead), but is it OK if my classes still implement SFSafariViewControllerDelegate? Will it cause problems on iOS8? What is the standard procedure here?


Solution

  • It will not cause a problem. Implementing a protocol is something that only matters to the compiler. At runtime, it only matters if you implemented the methods of the protocol or not. Implementing methods that won't be called when running under iOS 8 is no different than any other method that isn't called because it's not needed.