Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does "Enable Strict Checking of objc_msgSend Calls" mean?

This is what I'm referring to:
enter image description here

From what I've read, an objc_msgSend is essentially what is happening at the c level when you send an Objective-C message, and this setting set to Yes ensures that the message being sent has the same number of arguments as the the receiver is expecting.

Is this correct? Also what are the advantages and disadvantages to setting this to Yes or No? Should I only set this to Yes in development and No in production?

like image 337
Mike V Avatar asked Jan 04 '15 23:01

Mike V


2 Answers

You are essentially correct, yes.

Apple sets it to Yes by default because it helps to find errors faster. The only reason to set it to No would be because you are compiling legacy code that hasn't been updated to compile cleanly with this option on.

"Enable Strict Checking of objc_msgSend Calls" is a compile time check, not run time, so there is no benefit to turning it off in production.

like image 96
Joshua D. Boyd Avatar answered Oct 14 '22 04:10

Joshua D. Boyd


There's a presentation "What's new in LLVM" on Apple's website (text of the presentation is here).

It looks like the compiler will now (optionally) strictly check the types of calls to obj_msgSend. You will have use a correctly-typed function pointer in place of directly calling objc_msgSend.

Example given:

#include <objc/message.h>
void foo(void *object) {
  typedef void (*send_type)(void *, SEL, int);
  send_type func = (send_type)objc_msgSend;
  func(object, sel_getUid("foo:"), 5);
}
like image 7
nielsbot Avatar answered Oct 14 '22 02:10

nielsbot