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

Commit

Permalink
Merge pull request #1 from Jigsaw-Code/cohenjon-patch-pbjc-msgsend
Browse files Browse the repository at this point in the history
Correctly cast objc_msgsend calls to a function pointer with the right signature.
  • Loading branch information
daniellacosse authored Nov 5, 2021
2 parents 4e92b63 + ce1b7ad commit 07e62a5
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 07e62a5

Please sign in to comment.