0

I have 2 screens in my app that show (exercise) videos, one show videos that the user must do during that week. The other shows the history off all the weeks. The screens are almost the same except the first screen has an element to show the week number the other (history) does not.

When I click the history button in the first screen it shows the history video screen. At least it used to do, but I made almost no changes and upgraded to a later version of xcode and now I get the following error :

this class is not key value coding-compatible for the key weekLabel.

This is the code that induces the new screen to show the history videos :

   @IBAction func goToVideosHistory(_ sender: UIButton) {
        let exercisesHistoryVC = ExercisesHistoryViewController.instantiate(from: .Main)
        exercisesHistoryVC.modalPresentationStyle = .fullScreen
        parent?.present(exercisesHistoryVC, animated: true, completion: nil)
    }

My knowledge about Xcode is to less to debug this problem, the one thing I can see is that when I set a breakpoint just after the let exerciseHistoryVC and I check the UIview number it has a different number then when it crashes.

So my guess is that it loads the wrong view for my view controller. I know a little bit how Storyboard works, but I have no idea where Xcode/swift internally loads screens..

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
mistert69
  • 89
  • 1
  • 11
  • How does `AppDelegate` fits into your question? – El Tomato Aug 23 '21 at 08:23
  • 1
    Does this answer your question? [Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?](https://stackoverflow.com/questions/3088059/xcode-how-to-fix-nsunknownkeyexception-reason-this-class-is-not-key-valu) – Mikhail Vasilev Aug 23 '21 at 08:26
  • It would help if you included the full exception message, but essentially the view controller class that was instantiated doesn't have an `IBOutlet` called `weekLabel` - The full exception message will show the class that was instantiated. Also, presumably, `.instantiate(from:)` is an extension you have created on `UIViewController` or a class method on `ExerciseHistoryViewController` - You should show the source for that. – Paulw11 Aug 23 '21 at 08:30

0 Answers0