Skip to content

Instantly share code, notes, and snippets.

@ddeville
Last active December 20, 2015 05:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddeville/6078492 to your computer and use it in GitHub Desktop.
Save ddeville/6078492 to your computer and use it in GitHub Desktop.
objc_msgSend cast
So:
id boxedValue = objc_msgSend(self, mappingSelector, instance, value, boxingParameters);
would become:
id boxedValue = ((id (*)(id, SEL, id, id, id))objc_msgSend)(self, mappingSelector, instance, value, boxingParameters);
The first `id` and `SEL` are basically `self` and `_cmd`, the first 2 arguments in any objc_msgSend.
@krzysztofzablocki
Copy link

Does that look ok?

id (_objc_msgSendTyped)(id, SEL, id, id, NSArray _) = (void*)objc_msgSend;
boxedValue = objc_msgSendTyped(self, mappingSelector, instance, value, boxingParameters);

@ddeville
Copy link
Author

Pardon the mess with the arguments on the original version :(

Yeah that looks fine to me.

@0xced
Copy link

0xced commented Jul 25, 2013

There is an easy way to catch these errors:

With 10.8 SDK, #define OBJC_OLD_DISPATCH_PROTOTYPES 0 at the top of your file or PCH to get errors if you use objc_msgSend without a cast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment