Too many arguments to function call, expected 0, have 3

Any idea why such error when Apple Silicon enabled?
Too many arguments to function call, expected 0, have 3

The error is on line NSMethodSignature *ret = instanceMethodForSelectorIMP( self->targetObjectClass, @selector(instanceMethodSignatureForSelector:), aSelector );

Code Block
- (NSMethodSignature *)methodSignatureForSelector: (SEL)aSelector
{
 //DEBUGLOG( @"" );
 id obj = [ self resolveTargetObject ];
 if( obj == nil ){
  Method instanceMethod = class_getClassMethod( self->targetObjectClass, @selector(instanceMethodSignatureForSelector:) );
  IMP instanceMethodForSelectorIMP = method_getImplementation( instanceMethod );
      
  NSMethodSignature *ret = instanceMethodForSelectorIMP( self->targetObjectClass, @selector(instanceMethodSignatureForSelector:), aSelector );
  return ret;
 }
 return [ obj methodSignatureForSelector: aSelector ];
}



Answered by OOPer in 647505022

The error is on line NSMethodSignature *ret = instanceMethodForSelectorIMP( self->targetObjectClass, @selector(instanceMethodSignatureForSelector:), aSelector );

On the line, you are passing 3 arguments, Class, SEL, SEL. You need to tell it to the compiler.

Try changing the definition of instanceMethodForSelectorIMP:
Code Block
  id (*instanceMethodForSelectorIMP)(Class, SEL, SEL) = (id(*)(Class,SEL,SEL))method_getImplementation( instanceMethod );




Accepted Answer

The error is on line NSMethodSignature *ret = instanceMethodForSelectorIMP( self->targetObjectClass, @selector(instanceMethodSignatureForSelector:), aSelector );

On the line, you are passing 3 arguments, Class, SEL, SEL. You need to tell it to the compiler.

Try changing the definition of instanceMethodForSelectorIMP:
Code Block
  id (*instanceMethodForSelectorIMP)(Class, SEL, SEL) = (id(*)(Class,SEL,SEL))method_getImplementation( instanceMethod );




it worked, thanks
Too many arguments to function call, expected 0, have 3
 
 
Q