Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  158] [ 1]  / answers: 1 / hits: 15833  / 14 Years ago, mon, may 17, 2010, 12:00:00

In C or any ECMAscript based language you 'call a public method or function' on an object. But in documentation for Objective C, there are no public method calls, only the sending of messages.



Is there anything wrong in thinking that when you 'send a message' in ObjC you are actually 'calling a public method on an Object'.?


More From » objective-c

 Answers
206

Theoretically, they're different.



Practically, not so much.



They're different in that in Objective-C, objects can choose to not respond to messages, or forward messages on to different objects, or whatever. In languages like C, function calls are really just jumping to a certain spot in memory and executing code. There's no dynamic behavior involved.



However, in standard use cases, when you send a message to an object, the method that the message represented will usually end up being called. So about 99% of the time, sending a message will result in calling a method. As such, we often say call a method when we really mean send a message. So practically, they're almost always the same, but they don't have to be.



A while ago, I waxed philosophical on this topic and blogged about it: http://davedelong.tumblr.com/post/58428190187/an-observation-on-objective-c



edit



To directly answer your question, there's usually nothing wrong with saying calling a method instead of sending a message. However, it's important to understand that there is a very significant implementation difference.



(And as an aside, my personal preference is to say invoke a method on an object)


[#96761] Friday, May 14, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joanneamiyaa

Total Points: 532
Total Questions: 127
Total Answers: 98

Location: Guam
Member since Tue, Nov 3, 2020
4 Years ago
joanneamiyaa questions
Thu, Apr 30, 20, 00:00, 4 Years ago
Thu, Feb 20, 20, 00:00, 4 Years ago
Mon, Oct 14, 19, 00:00, 5 Years ago
;