Is it possible to programmatically retrieve the identifier of a base UIViewController from a UIViewController or Storyboard in Swift / Objective-C?

I know that we can create an instance of a specific UIViewController based on its identifier (see below):

var myPageContentViewController = self.storyboard!.instantiateViewControllerWithIdentifier("A") as PageContentViewController 

But my question does not concern this point, in other words, I just wanted to know whether it is possible to programmatically (in the source code) get the identifier (in our case the string value "A"), which I set in the storyboard for this particular PageContentViewController (which is subclass of UIViewController in my project)?

Note: an answer using the Swift development language instead of the Objective-C development language would be more convenient for me, even if I know the latter. For your information, I use version X.1.0 version 6.0.1.

Thank you in advance for your answers.

+5
source share
2 answers

In Swift:

  var str: String! = self.restorationIdentifier 
+11
source

You can get the UIViewController identifier using the recovery identifier with the following code in the C object:

 NSString *restorationId = self.restorationIdentifier; 

Hope this helps you.

+10
source

Source: https://habr.com/ru/post/1204150/