#import <objc/runtime.h>
需求:首页的轮播需要随意跳转页面
引用runtime头文件
NSDictionary *dic = @{@"1":@"TYSqliteVCViewController",@"2":@"KevinTestViewController"};
NSDictionary*paramDic =@{@"name":@"tianye"};
NSString *class = dic[[NSString stringWithFormat:@"%d",1]];
const char *className = [class cStringUsingEncoding:NSASCIIStringEncoding];
ClassnewClass =objc_getClass(className);
if(!newClass) {
ClasssuperClass = [NSObjectclass];
newClass =objc_allocateClassPair(superClass, className,0);
//注册你创建的这个类
objc_registerClassPair(newClass);
}
idinstance = [[newClassalloc]init];
[instancesetValue:paramDicforKey:@"paraDic"];
[self presentViewController:instance animated:NO completion:^{
}];