Reputation: 1466
I've already looked at the following for guidance to no avail:
How to know the current storyboard name?
I am trying to open a specific view controller using my storyboard from a remote notification based off of the following answer:
Present specific view controller in didReceiveRemoteNotification with Swift
let mvc = MainViewController()
let storyBoardNameString = mvc.storyboard. //<-proposed solution? Nothing from auto complete shows up
let storyboard = UIStoryboard(name: storyBoardNameString , bundle: nil)
storyboard.instantiateViewControllerWithIdentifier("some-view-controller")
I've checked the "File inspector", "Quick help inspector", "Identity inspector", "Attributes inspector", "Size inspector", and even the "Connections inspector" with no luck there either.
When I selected a view controller on my storyboard and tried to find the name of the current storyboard I was only able to find the view's Storyboard ID, not the name of the storyboard however.
Any solution would be greatly appreciated, otherwise I will try to find another way to accomplish my task.
Upvotes: 3
Views: 4836
Reputation: 440
Maybe my answer is not right to your question, but you can take a look and think about it.
Make a payload format, and create the specific UIViewController with it.
let payload = ["storyboard" : "StoryboadNameYouWant", "viewcontroller" : "ViewControllerName", "parameters" : "YourParameters"]
func handlePayload(payload: Dictionary<String, String>) {
let storyboard = UIStoryboard(name: payload["storyboard"]!, bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier(payload["viewcontroller"]!)
// present vc
}
Upvotes: 1
Reputation: 1112
Try following code it may helps you.
let mvc = MainViewController()
let storyBoardNameString = mvc.restorationIdentifier!//it will give identifier
let storyboard = UIStoryboard(name: storyBoardNameString , bundle: nil)
storyboard.instantiateViewControllerWithIdentifier("some-view-controller")
Upvotes: 0
Reputation: 1466
My colleague just informed me it's the name of the file without the ".storyboard" extension. Regards.
Upvotes: 8