Before discussing Swift method calls optimization, it would be very useful to have a look at different types of method call implementation.
There are two main types of method call:
- Static: Static method binding means that, when you call a method on the object, the compiler knows that you are calling exactly this method on exactly this class. C is an example of a language with static method binding.
- Dynamic: On other hand, dynamic has a weak binding between the method and the object. When you call a method on the object there is no guarantee that an object can handle this method call. Objective-C has a dynamic method binding. That's why you can see the
object does not respond to selector error in Objective-C.
Objective-C is a dynamic-type ...