ViewController Storyboard ID from a variable

Viewed 167

How can I set in the Storyboard a ViewController Storyboard ID from a variable in a struct swift file?

I don't want to write down the Storyboard ID of a VC from the Identity Inspector > Identity > StoryboardID hardcoded. I want it to be in a variable in a struct swift file where I can access it and also set it/change it from there.

1 Answers

From Apple docs. https://developer.apple.com/documentation/uikit/uistoryboard/1616214-instantiateviewcontroller

An identifier string that uniquely identifies the view controller in the storyboard file. You set the identifier for a given view controller in Interface Builder when configuring the storyboard file. This identifier is not a property of the view controller object itself and is used only by the storyboard file to locate the view controller.

If the specified identifier does not exist (or is nil) in the storyboard file, this method raises an exception.

As storyboardID is not the property of the ViewController or some other class we may not access this property.

Related