I'm trying to recreate a small iOS app that utilized nib files. I'm trying to replace the following line of code

 self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

with:

UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController* viewController = [sb instantiateViewControllerWithIdentifier:@"viewController"];    self.window.rootViewController = self.    viewController;

I'm getting the following error: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'viewController''

I got the latter code from a previous Stack Overflow question on a similar topic. Can someone please advise on what the issue I'm having is and how to proceed?

有帮助吗?

解决方案

You need to name the view controller in your storyboard by giving it a storyboard id. I typically try to use something memorable like the name of the view controllers class so I don't have to look it up.enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top