IMP用法
2019-03-12 本文已影响0人
elephant0001
/// 请求回调 通用处理
- (void)makeCommonResponse:(id)responseObject selector:(SEL)selector {
int code = [response ObjectintForKey:@"status"];
NSString *msg = [response ObjectstringForKey:@"msg"];
if(code ==200) {
IMP imp = [self methodForSelector:selector];
void(*func)(id,SEL,id) = (void*)imp;
func(self, selector, responseObject);
}
}
可以调用传过来的 方法!