I'm near the end of translating my code from Objective-C to Swift and I started switching the view controller classes to Swift. I managed to fix most of the problems with the view controllers but I keep getting this error for one of my View controllers.
When it crashes: "Thread 1 signal sigabrt"
The error log:
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<UIViewController 0x7fd98fc65ee0> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key background.'
Note: "background" in this case is a UIImageView Outlet.
I been through multiple stack over flow solutions and none seem to help me. I've tried:
Cleaning the build folder
Deleting the app on the simulator
Deleting the derived folder
Checking for extra IBOutlets
Deleting the connections and reconnecting them
Renaming the outlet
Checking for extra connections in storyboard
Debugging the viewDidLoad() function
Here is my code:
IBOutlet var background: UIImageview!
override func viewDidLoad() {
super.viewDidLoad()
let image: UIImage = UIImage(named: UserDefaults.standard.string(forKey: "Background")!)!
background.image = image
...
}