Last active
December 20, 2015 05:29
-
-
Save ddeville/6078492 to your computer and use it in GitHub Desktop.
objc_msgSend cast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Pardon the mess with the arguments on the original version :(
Yeah that looks fine to me.
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
Does that look ok?
id (_objc_msgSendTyped)(id, SEL, id, id, NSArray _) = (void*)objc_msgSend;
boxedValue = objc_msgSendTyped(self, mappingSelector, instance, value, boxingParameters);