4

Here is a screenshot from Xcode 8.2:

enter image description here

If the function does not exist, how do you add identifier to a view controller these days?

1
  • It's func instantiateViewController(withIdentifier identifier: String) -> UIViewController. Note that the initialViewController don't need to have a identifier to be called (func instantiateInitialViewController() -> UIViewController?). Commented Dec 19, 2016 at 16:28

2 Answers 2

5

Use instead instantiateViewController(withIdentifier:) when you would like a ViewController and attach a view from the storyboard (UIStoryboard Id Identifier)

instantiateInitialViewController() is to instantiate the default view initial, this function takes no argument and is something you wouldn't usually do programmatically.

Sign up to request clarification or add additional context in comments.

1 Comment

there's no argument to func instantiateInitialViewController() use instantiateViewController instead
4
let sb = UIStoryboard(name: "", bundle: Bundle.main) sb.instantiateViewController(withIdentifier: "blue") 

1 Comment

Swift 5: Cannot convert return expression of type 'UIStoryboard' to return type 'UIViewController' when I try to return

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.