As simple as this question may seem, I just couldn't figure it out. To the overflow community, I am using sprite kit to create a simple game, However when you lose the game I want to programmatically segue back to another viewController (basically the home screen). from The game scene I do not get access to "performSegueWithIdentifier" I've seen a couple answers that relate to this topic however non of them are in swift ... Any solutions? links of related questions include : Link1 Thank You
Asked
Active
Viewed 209 times
2 Answers
0
I think you are misunderstanding SKViews. SKViews are just like a normal UIViews, they take place within a normal ViewController. You will therefore need to segue from the ViewController which is presenting your SKView.
I have the same issue in a game I have created (Ninja-Shooter). In my game, whenever I want to segue back the home screen I pass a value to NSUserDefaults.standardUserDefaults()
. Then in my ViewController I am constantly listening for any change in that value, if the value does change, then I perform a segue.
Hope this helps!

Alex Chesters
- 3,380
- 5
- 19
- 27
-
I see what you mean by what an SKView is , but what function can allow you to constantly listen for changes in value in your view controller ? @Alex – Chris Mazile Jun 09 '15 at 17:08
-
http://stackoverflow.com/questions/21916702/go-back-to-view-controller-from-skscene this link actually describes exactly what I wish to accomplish, can anyone translate to swift? – Chris Mazile Jun 09 '15 at 19:03
-
Admittedly mine is a poor implementation (I am still relatively new to Swift), I have a function which runs every 0.1 second which checks if the value has changed – Alex Chesters Jun 10 '15 at 06:42
0
I have discovered that using NSNotification Center Can in fact derive the results I was looking for. If any one in the future needs detailed code I will edit to provide that

Chris Mazile
- 23
- 7