-3

i am setting up a userdefualt integer and when i segue to the page the app crashes. It shows the appDelegate with it says " Thread 1: signal SIGBART" and in the debugger it says "libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) "

Her is my code, please help me find the error:

class home: UIViewController {
@IBOutlet weak var fiveth1: UILabel!
@IBOutlet weak var iron1: UILabel!
@IBOutlet weak var gold1: UILabel!
@IBOutlet weak var ships1: UILabel!
@IBOutlet weak var empires1: UIWebView!

@IBOutlet weak var webViewG: UIWebView!
override func viewDidLoad() {
    super.viewDidLoad()

    let htmlPath1 = Bundle.main.path(forResource: "WebViewContent2", ofType: "html")
    let htmlURL1 = URL(fileURLWithPath: htmlPath1!)
    let html1 = try? Data(contentsOf: htmlURL1)

    self.webViewG.load(html1!, mimeType: "text/html", textEncodingName: "UTF-8", baseURL: htmlURL1.deletingLastPathComponent())


    if (Fiveth.value(forKey: "Fiveth") != nil){
        fiveth = Fiveth.value(forKey: "Fiveth") as! NSInteger!
        fiveth1.text = NSString(format: "Fiveth: %i", fiveth) as String
    }

    fiveth1.text = "\(Fiveth)"
}

enter image description here enter image description here

Oren Edrich
  • 674
  • 1
  • 7
  • 23

1 Answers1

3

The issue is that you have an NSUnknownKeyException for the key 'empires'. This is usually caused by an outlet in the Storyboard that doesn't match the name in code. You most likely created an outlet when the variable was called empires before you re-named it to empires1.

To fix this, disconnect and re-connect the outlet in the storyboard.

nathangitter
  • 9,607
  • 3
  • 33
  • 42