In Objective-C, does the binding of method really happen at “run-time”?

前端 未结 4 1453
忘了有多久
忘了有多久 2021-01-24 00:41

I heard that Objective-C is influenced by the \"message passing mechanism\" of SmallTalk.

Objective-C, like Smalltalk, can use dynamic typing: an object

4条回答
  •  礼貌的吻别
    2021-01-24 01:04

    One job of a compiler is to catch as many errors at compile time as possible. If it can tell that the call will fail at runtime, you generally want it to complain.

    You can suppress this via casting to show that runtime resolution is happening:

    [(id)brad sayHelloTest];
    

提交回复
热议问题