What\'s the difference between marking a method as @objc vs dynamic, when would you do one vs the other?
Below is Apple\'s definition for dynamic.
To work with Objective-C
from Swift
you have at least two reserved words:
@objc
[About] - Compile time - To expose Swift's api for Objective-C runtime. For example a framework which was written on Swift can use @objc
for:
#selector
[About] in a Swift codedynamic
- Run time - to enable a message dispatch
(Objective-C's world) for NSObject
object, which is different than virtual dispatch (table dispatch)
(Swift's world). It is used for:
class extensions
to have a possibility to override an extension functionBefore Swift v4
dynamic
included @objc