Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception thrown #1

Open
jessephillips opened this issue May 19, 2020 · 1 comment
Open

exception thrown #1

jessephillips opened this issue May 19, 2020 · 1 comment

Comments

@jessephillips
Copy link

Forgive me if this is silly for me to suggest. But I got an error when running this app with only some small code changes I made. I'm wondering if something is funky. As a novice, I wasn't able to figure out the problem.

Here's my error:
Thread 1: Exception: "[<Magic_8_Ball.ViewController 0x7fbd385071e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key askButtonPressed."

my code: viewcontroller.swift
`import UIKit

class ViewController: UIViewController {

@IBOutlet weak var imageView: UIImageView!

@IBAction func askButtonPressed(_ sender: UIButton) {
    let ballsArray = [#imageLiteral(resourceName: "ball3"),#imageLiteral(resourceName: "ball3"),#imageLiteral(resourceName: "ball5"),#imageLiteral(resourceName: "ball2"),#imageLiteral(resourceName: "ball1")]
    imageView.image = ballsArray.randomElement()
}

}`

@Ramstan1010
Copy link

Hey @jessephillips, I also ran into this problem and it ended up being due to calling it something different originally and even though I did a refactor to rename it, it still didn't resolve. In your case it looks like you called it what you should so I'm not sure why, but I ended up searching for my incorrect button name (CMD+F) with the Main.Storyboard open and found it still existing incorrectly in the Connections Inspector (top right of screenshot). I deleted it from there and then remade the IBAction and it resolved my issue. Hope this helps!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants