运行时代码用来写UITableView配置界面选中

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    Class clazz = NSClassFromString([items_ objectAtIndex:indexPath.row]);
    id viewController = [[clazz alloc] init];
    if (viewController) {
        [self.navigationController pushViewController:viewController animated:YES];
    }
}

消息转发、运行时为类添加方法、运行时替换类方法的实现,枚举类的方法和属性,获得方法的签名信息等等,都算运行时编程。

枚举类的方法?类别是在运行时进行的

猜你喜欢

转载自lizhuang.iteye.com/blog/1920915