objC's message passing - compiler won't check whether method is existing?
In Objective-C's Wiki page, there is a section named Messages. It says
when compiling, Objective-C doesn't care whether an object has a given
method, because anyone can send a message to another. This is dynamic
binding.
in C++, obj->method(argument); if no method, wrong. in Objective-C, [obj
method:argument]; if no method, can be fine.
But in my daily coding, with XCode, if compiler cannot find a public
method of an object, it always prompt error even before build. like this,
no visible @interface for 'ClassName' declares the selector 'methodName'
I am a little confused about this 'contradiction'. Please forgive me if
the question is silly. thanks in advance.
No comments:
Post a Comment