I'm trying to run the method id method_invoke ( id receiver, Method m, ... ); from the Objective-C runtime library but the compiler is saying I'm passing too many arguments, with it expecting 0. Why might this be? (swizzledMethodOriginalImplementation is of type Method)
-(NSMenu*) blah2: (NSEvent*)anEvent :(NSRect) cellFrame :(NSView*) aView {
NSMenu *contextMenu = method_invoke(self, swizzledMethodOriginalImplementation, anEvent, cellFrame, aView);
}
You're using
method_invokewrong. One must never actually callmethod_invokedirectly. It doesn't know what arguments to expect. That is why its declaration, in the documentation, is written in a completely open-ended form:One must first cast the
method_invokefunction to the correct function pointer type for the method in question. I don't see you doing that.