42

The instantiateViewControllerWithIdentifier: method requires that the view controller I pass have an identifier. I went to my storyboard and clicked on my view controller, but I see no option to set the identifier. Where exactly do I find this option?

Doug Smith
  • 29,668
  • 57
  • 204
  • 388

3 Answers3

72

As the Image suggests! Hope it helps!

enter image description here

Then to use it you call:

[self.storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerID"];
Groot
  • 13,943
  • 6
  • 61
  • 72
14

Updated for XCode 8 and Swift 3.

instantiateViewControllerWithIdentifier is now instantiateViewController(withIdentifier:).

Setting the storyboard ID: enter image description here

Taiwosam
  • 469
  • 7
  • 13
  • 1
    More on instantiateViewController(withIdentifier:) https://developer.apple.com/documentation/uikit/uistoryboard/1616214-instantiateviewcontroller – Taiwosam Aug 18 '17 at 12:50
5

In the identity inspector there is a field Storyboard ID. You could enter the class name here and then use this identifier in instantiateViewControllerWithIdentifier:.

Felix
  • 35,354
  • 13
  • 96
  • 143