Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between Message & Method  RSS feed

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody here, who knows objective C tell the difference between Message & Method?

What I think is they both are same.
 
ranger
Sheriff
Posts: 17314
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Semantics.

Objective-C doesn't call it methods. You send messages to an Object. The Object might or might not respond to the Message, which doesn't automatically cause it to fail. It can keep going.

In Java method calls, it can't keep going, either the class has the method or not, it is a compile time thing now.

Mark
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mark Spritzler wrote:Semantics.

Objective-C doesn't call it methods. You send messages to an Object. The Object might or might not respond to the Message, which doesn't automatically cause it to fail. It can keep going.



This is why if you try and access a method on an Objective-C object that doesn't exist, you simply get a "Foo may not respond to -bar" warning rather than an error. This is one of my least favorite things about Objective-C.
 
Die Fledermaus does not fear such a tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!