Re: Can I advantage of Swift availability features in a UITableVIewDelegate?

Bernie Maier

Rick Aurbach:

I don't understand how to use @availabiltiy and/or #availability to
implement the above requirement when I am implementing optional protocol
functions. (I think I understand what to do when the conditional code is
mine, but I'm not sure how this applies to implementation of optional
protocol functions in system-defined protocols.)
If I understand you correctly, you are asking whether you can wrap entire function implementations inside availability guards, vs just a section of code within a function.

I suspect you don't need to do that in the case you describe. Just implement both sets of delegate functions. When you compile against the iOS 11 SDK, everything will compile fine. The new delegate methods won't be called in iOS 10.x. You may need to "availability wrap" the code inside the implementation of tableView(_:editActionsForRowAt:) so that when the app is running under iOS 11+, both sets of delegate methods don't compete with each other.


Join { to automatically receive all group messages.