Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Patrick Li
Patrick Li
2,434 Points

segue Identifier not working

import UIKit
import SpriteKit

extension SKNode {
    class func unarchiveFromFile(file : NSString) -> SKNode? {
        if let path = NSBundle.mainBundle().pathForResource(file as String, ofType: "sks") {
            var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)!
            var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData)

            archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene")
            let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene
            return scene
        } else {
            return nil

class GameViewController: UIViewController{

    override func viewDidLoad() {

        if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
            // Configure the view.
            var skView = self.view as! SKView
            skView.showsFPS = false
            skView.showsNodeCount = false

            /* Sprite Kit applies additional optimizations to improve rendering performance */
            skView.ignoresSiblingOrder = true

            /* Set the scale mode to scale to fit the window */
            scene.scaleMode = .AspectFill


    override func shouldAutorotate() -> Bool {
        return true

    override func supportedInterfaceOrientations() -> Int {
        if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
            return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
        } else {
            return Int(UIInterfaceOrientationMask.All.rawValue)

    override func didReceiveMemoryWarning() {
        // Release any cached data, images, etc that aren't in use.

    override func prefersStatusBarHidden() -> Bool {
        return true

    func move(){
        performSegueWithIdentifier("fromGameMoveToMenu", sender: self)

This is my GameViewController. I hold the reference to this class in a different playscene. I am able to call func move(){}, so there is nothing wrong with actually calling the function. I also have a segue in my main storyboard connecting my GameViewController to my MenuViewController. The segue identifier is named "fromGameMoveToMenu". The error says that it cannot find the segue identifier. However, if i put the same performseguewithidentifier function in the viewwillappear, then it will work. Please help!