Reputation: 693
When I click a button it triggers this function
@IBAction func groupSquare1Tapped(_ sender: Any) {
userDefaults.set(userDefaults.array(forKey: "groupNames")![0], forKey: "currentGroup")
openMessages()
}
I get the error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Nebula.MessagingViewController 0x15d00ed70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key scroll.'
It used to work fine but I do now know what is changing.
The openMessages()
function just changes the view. When I run the userDefaults
line out of the function it works fine so it is not that.
How can I fix this?
Upvotes: 0
Views: 62
Reputation: 131511
When you get an NSUnknownKeyException crash, it is often because you have an IBAction
defined in your Storyboard (or XIB file) linked to a view controller that does not implement the method named in the IBAction. In this case, it sounds like the action is "scroll".
Try opening the connection inspector in Interface Builder, selecting the button in question, and clicking the X(es) to delete all the IBActions on that button. Then control-drag from the button to your IBAction method to re-establish the link.
Upvotes: 1