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?
Asked
Active
Viewed 4.4k times
42

Doug Smith
- 29,668
- 57
- 204
- 388
3 Answers
72
As the Image suggests! Hope it helps!
Then to use it you call:
[self.storyboard instantiateViewControllerWithIdentifier:@"YourViewControllerID"];

Groot
- 13,943
- 6
- 61
- 72
-
can i set it programmatically please help – Jul 11 '18 at 13:09
-
@user9395315 No you can't set the storyboardID programmatically – mfaani Mar 31 '20 at 19:18
14
Updated for XCode 8 and Swift 3.
instantiateViewControllerWithIdentifier
is now instantiateViewController(withIdentifier:).

Taiwosam
- 469
- 7
- 13
-
1More 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