Method calls
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 language and it has a dynamic runtime. Calling a method is called message sending. You send a message to the target.
[dog bark] // dog is a target and bark is a message
This looks like a normal method call, but after compilation it would actually...