2

The concept of message is normally associated with asynchronous call. Is it the case for Objective C ? ie when a caller sends a message to a callee to execute a method on it, does the caller continues immediately or is it blocked until the callee finishes executing the method requested ?

user310291
  • 36,946
  • 82
  • 271
  • 487

2 Answers2

3

It is definitely blocked. Because the messages are actually translated in plain C.

[myObj myMethod];

becomes

objc_msgSend(myObj, @selector(myMethod));

at run time.

However, some methods are implemented to be asynchronous. See -[NSTask launch], -[NSThread start], etc.

v1Axvw
  • 3,054
  • 3
  • 26
  • 40
  • +1, but for those asynchronous methods, the actual method is run synchronously. It's just that the work the method does is started & performed asynchronously. There's no way to make a message send asynchronous. – wbyoung Apr 15 '12 at 14:01
  • Thanks then my next question http://stackoverflow.com/questions/10163489/how-to-send-message-asynchronously-in-objective-c excluding specific methods you mentioned. – user310291 Apr 15 '12 at 15:44
2

No, when you read "send a message" in objective-c you must think of it as calling a method. So, to send a message is to call a method, some are sync, some are async, you must check the docs to see that.

fbernardo
  • 10,016
  • 3
  • 33
  • 46