在调用IPM的时候报了`Too few arguments to function call, expected at least 2, have 0`的错
来源:4-1 类方法和实例方法之间的区别
风儿想嚯奶茶
2019-03-06
我在学习的时候,按照老师的示例代码,
@interface TestClass : NSObject
//
-(void)testLog;
//
+(void)testLog;
@end
//=============================== 实例方法
SEL sel = @selector(testLog);
IMP imp = class_getMethodImplementation([TestClass class], sel);
imp();
//=============================== 类方法
SEL testSel = @selector(testLog);
NSString *className = [NSString stringWithFormat:@"%s",class_getName([TestClass class])];
NSLog(@"className===============%@",className);
IMP testImp = class_getMethodImplementation(objc_getMetaClass(class_getName([TestClass class])), testSel);
testImp();
编译的时候报错:
Too few arguments to function call, expected at least 2, have 0

我设置objc_msgSend为NO,还是会报这个错。
在Stack Overflow上提问,但目前没有人给出解决方案,请问这个造成这个错误的原因是什么呢,应该如何解决。
写回答
1回答
-
风儿想嚯奶茶
提问者
2019-03-06
问题解决了,修改`objc_msgSend`为YES,就OK了。
012019-03-07
相似问题