Programmatically get a Storyboard ID?

Trying to see if a UIViewController or UIView can identify its Storyboard ID. So was hoping for:

UIViewController *aViewController;
NSString *storyboardID = aViewController.storyboard.id;  //not an actual property

or:

NSString *storyboardID = [aViewController.storyboard valueForKey:@"storyboardId"];  //also not a working call

But no joy and couldn't find a similar solution online. Does anyone know if this is even possible?


Solution 1:

You can use the restorationIdentifier, it's right above the Storyboard identifier and it's a UIViewController property.

Solution 2:

You can use the Restoration ID:

NSString *restorationId = self.restorationIdentifier;

Just check the checkbox 'Use Storyboard ID'

Solution 3:

The storyboard id is only meant to find and instantiate a VC from a storyboard. As written in the UIStoryboard reference:

"This identifier is not a property of the view controller object itself and is only used by the storyboard file to locate the view controller."

Why do you need it?