0

I am getting this error:

2015-04-12 21:54:22.231 yyyy.temp_caseinsensitive_rename[17700:922790] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<yyyy_temp_caseinsensitive_rename.PatternGameViewController 0x7fd4fa773000> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Level.'

Here is all my code:

class PatternGameViewController : UIViewController{

var screenSize: CGRect = UIScreen.mainScreen().bounds
var backButton : UIButton = UIButton(frame: CGRect(x: 5, y: 5, width: 5, height: 5))
var drawUI : DrawUI = DrawUI(UIView(frame: CGRect(x: 5, y: 5, width: 5, height: 5)), CGRect(x: 5, y: 5, width: 5, height: 5))

@IBOutlet weak var circle: UIButton!
@IBOutlet weak var square: UIButton!
@IBOutlet weak var triangle: UIButton!
@IBOutlet weak var star: UIButton!
@IBOutlet weak var label: UILabel!

var buttonClicked : Int = 6

override func viewDidLoad() {
    super.viewDidLoad()
    drawUI = DrawUI(self.view, self, screenSize)
    drawUI.drawTopRect()
    drawUI.drawBotRect()
    drawUI.setBackgroundDefault()
    drawBackButton()

    label.text = "Level: 1"

}



func runGame(){
    var past : [Int] = [0]
    var level = incrementGame(past)
}
func incrementGame(past123 : [Int]) -> [Int]{
    label.text = "Ready? Enter the following:"
    sleep(1)
    var past : [Int] = [0]
    var currentSelectedShape : Int = 0
    for i in past123{
        past.append(past123[i])
        currentSelectedShape = past[i]
        if(currentSelectedShape == 0){
            label.text = "circle"
            sleep(1)
        }
        else if(currentSelectedShape == 1){
            label.text = "square"
            sleep(1)
        }
        else if(currentSelectedShape == 2){
            label.text = "triangle"
            sleep(1)
        }
        else if(currentSelectedShape == 3){
            label.text = "star"
            sleep(1)
        }
        if(i == past123.count){
            currentSelectedShape = randomInRange(0, hi:3)
            if(currentSelectedShape == 0){
                label.text = "circle"
                sleep(1)
            }
            else if(currentSelectedShape == 1){
                label.text = "square"
                sleep(1)
            }
            else if(currentSelectedShape == 2){
                label.text = "triangle"
                sleep(1)
            }
            else if(currentSelectedShape == 3){
                label.text = "star"
                sleep(1)
            }
        }

    }
    past.append(currentSelectedShape)
    for i in past{
        while(buttonClicked == 6){

        }
        if(buttonClicked == i){

        }
        else{
            return past
        }
    }
    return incrementGame(past)
}

@IBAction func circleClicked(sender: AnyObject) {
    self.buttonClicked = 0
}
@IBAction func squareClicked(sender: AnyObject) {
    self.buttonClicked = 1
}
@IBAction func triangleClicked(sender: AnyObject) {
    self.buttonClicked = 2
}
@IBAction func starClicked(sender: AnyObject) {
    self.buttonClicked = 3
}
}

No idea what to do. I have searched throughout my code with any variable called 'Level' and can not find anything. Although I have experienced this error before and have been able to solve it I am completely lost right now.

Wyler
  • 77
  • 1
  • 8
  • Add a exception breakpoint and show us where it breaks :-) – Schemetrical Apr 13 '15 at 02:51
  • 1
    Look in your storyboard. You might of once created an `@IBOutlet` for a control called `Level` that no longer exists. Look in the scene associated with the `PatternGameViewController` view controller. – Rob Apr 13 '15 at 02:52
  • @Rob Yep that is the issue... how do I solve it? I have tried re attaching the (at)IBOutlet but it did not fix the error. – Wyler Apr 13 '15 at 03:08
  • You have to remove that outlet to `Level`. Go to the "Connections inspector" (the last tab on the panel on the right) when viewing that scene in Interface Builder. You'll see the outlet to `Level` there, most likely. Just click on the little "x" next to the outlet to remove it. – Rob Apr 13 '15 at 03:10

0 Answers0