3

In my app, there are three storyboard. What I'd like to know is how to get a storyboard id/name in a viewcontroller code since UIStoryBoard init func takes first parameter name: String. where it stored and how to access it?

user584819
  • 1,509
  • 3
  • 12
  • 8
  • `UIViewController` have `storyboard: UIStoryboard?` property from which the view controller originated. Do you looking for it or for something else? – Yury Jun 21 '16 at 14:27
  • class UIStoryboard does not have a property or method to get it's name/id.in Swift. Or maybe I miss soemthing – user584819 Jun 21 '16 at 15:26
  • Possible duplicate of [Is it possible to programmatically get the identifier of a basic UIViewController from an UIViewController or Storyboard in Swift/Objective-C?](https://stackoverflow.com/questions/26229355/is-it-possible-to-programmatically-get-the-identifier-of-a-basic-uiviewcontrolle) – Dieblitzen Aug 06 '17 at 17:24

4 Answers4

4

The storyboard name is the name of the .storyboard file itself, but without the .storyboard extension.

The UIViewController's storyboard ID cannot be gotten, unless you have the restoration ID set to the storyboard ID and then you use

self.restorationIdentifier
Code
  • 6,041
  • 4
  • 35
  • 75
2

It is not possible to get thestoryboard's name without using private APIs.

A7medM
  • 189
  • 2
0

To get the name of a storyboard, just go to your storyboard file, and don't click on any of the View Controllers. Open up the File Inspector, and on the first tab, at the top it will have your name (ie. "Main.storyboard"). It's also just the file name typically. However, the best way to get at a storyboard is just to get at the storyboard property.

A. Ayyakad
  • 23
  • 6
0

You can use self.title to get the name of the ViewController