//调用类的时候使用 类方法
Class cls = NSClassFromString([NSString stringWithUTF8String:className]);
//把OC的字符串转化为Class类型
//cls 就可以执行/调用 cls 代表的类的加方法
id test = [[cls alloc]init];
if (test) {
SEL fun = NSSelectorFromString([NSString stringWithUTF8String:funcName]);
if ([test respondsToSelector:fun]) {
[test performSelector:fun];
}else{
NSLog(@"没有这个技能");
}
}else{
NSLog(@"输入的装备有误");
}
//我们编译代码不知道要使用哪个类 不直到调用什么方法;这个时候我们就可以用Class SEL
调用类的时候使用的类方法和SEL
最新推荐文章于 2022-04-14 13:04:27 发布