创建运行时已知的类的实例
我有这段代码,但它返回“nil”而不是一个新类。 在这里它是无用的,但在我的程序中它是有意义的。
Class myClass = [SettingsTableViewController class];
UIViewController *targetViewController = [[myClass alloc] initWithNibName:nil bundle:nil];
[[self navigationController] pushViewController:targetViewController animated:YES];
I have this code but it returns "nil" instead of a new class.
Here it is useless but in my programme it makes sens.
Class myClass = [SettingsTableViewController class];
UIViewController *targetViewController = [[myClass alloc] initWithNibName:nil bundle:nil];
[[self navigationController] pushViewController:targetViewController animated:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你忘记了一些事情或者你可能不知道。这是正确的代码。
You are forgetting something or you might don't know. Here is the proper code.