swift命名空间
- (id)productWithClassName:(NSString *)claName{
class cla = NSClassFromString(claName);
if (cla) {
id obj = [[cla alloc] init];
return obj;
}
}class ViewController: UIViewController {
public var dataSource:[[String:String]] = [["title":"pageOne","class":"PageOneViewController"],
["title":"pageTwo","class":"PageTwoViewController"]];
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.title = "首页"
let tableView:UITableView = UITableView.init(frame: self.view.bounds, style: UITableViewStyle.plain);
tableView.delegate = self;
tableView.dataSource = self;
self.view.addSubview(tableView);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}Last updated