ios - Message passing - compiler won't check whether method is existing? -


in objective-c's wiki page, there section named messages. says when compiling, objective-c doesn't care whether object has given method, because can send message another. dynamic binding.

in c++, obj->method(argument); if no method, wrong. in objective-c, [obj method:argument]; if no method, can fine.

but in daily coding, xcode, if compiler cannot find public method of object, prompt error before build. this,

no visible @interface 'classname' declares selector 'methodname'

i little confused 'contradiction'. please forgive me if question silly. in advance.

chances use arc. compiling arc-enabled code, compiler needs know type of objects method expects arguments , returns return value in order able emit necessary calls memory management methods. so, when compiling arc code, compiler will check if method signature exists.

if you, however, use manual reference counting (mrc), compiler doesn't need information for purpose (some of still necessary generating code comformant abi), , doesn't issue error if can't find message/method/selector. does, however, emit warning safety.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -