Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Correctly cast objc_msgsend calls to a function pointer with the righ…
Browse files Browse the repository at this point in the history
…t signature.
  • Loading branch information
Jonathan Cohen committed Sep 17, 2021
1 parent 15706d7 commit ce1b7ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CordovaLib/CordovaLib/Classes/CDVBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ - (void) exec:(NSString*) callbackId withService:(NSString*) service andAction:(
SEL normalSelector = NSSelectorFromString(methodName);
if ([obj respondsToSelector:normalSelector]) {
// [obj performSelector:normalSelector withObject:command];
objc_msgSend(obj, normalSelector, command);
// See https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html
((void (*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command);
} else {
// There's no method to call, so throw an error.
NSLog(@"ERROR: Method '%@' not defined in Plugin '%@'", methodName, command.cmdClassName);
Expand Down
3 changes: 2 additions & 1 deletion CordovaLib/CordovaLib/Classes/Commands/CDVCommandQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ - (BOOL) execute:(CDVInvokedUrlCommand*) command {
// Test for the legacy selector first in case they both exist.
if ([obj respondsToSelector:normalSelector]) {
// [obj performSelector:normalSelector withObject:command];
objc_msgSend(obj, normalSelector, command);
// See https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html
((void (*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command);
} else {
// There's no method to call, so throw an error.
NSLog(@"ERROR: Method '%@' not defined in Plugin '%@'", methodName, command.cmdClassName);
Expand Down

0 comments on commit ce1b7ad

Please sign in to comment.