Skip to content

Instantly share code, notes, and snippets.

@cocoajin
Last active December 26, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocoajin/7096073 to your computer and use it in GitHub Desktop.
Save cocoajin/7096073 to your computer and use it in GitHub Desktop.
创建一个类从NSString字条串
NSString *className = [item[kItemKeyClassPrefix] stringByAppendingString:@"ViewController"];
if (NSClassFromString(className)) {
Class aClass = NSClassFromString(className);
id instance = [[aClass alloc] init];
if ([instance isKindOfClass:[UIViewController class]]) {
[(UIViewController *)instance setTitle:item[kItemKeyTitle]];
[self.navigationController pushViewController:(UIViewController *)instance
animated:YES];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment