Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialhum4n01d
25,493 PointsGetting an error with my button
Here is my view controller:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var funFactLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
funFactLabel.text = "An interesting fact"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func showFact() {
let facts = ["Ants stretch when they wake up in the morning", "Ostriches can run faster than horses"]
funFactLabel.text = facts[1]
}
}
And here is the error:
2016-11-23 11:12:13.838 FunFacts[27083:4301691] -[FunFacts.ViewController showFact]: unrecognized selector sent to instance 0x7f9f76f056f0
2016-11-23 11:12:13.886 FunFacts[27083:4301691] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FunFacts.ViewController showFact]: unrecognized selector sent to instance 0x7f9f76f056f0'
*** First throw call stack:
1 Answer
hum4n01d
25,493 PointsWell I figured it out :) For some reason I had two actions attached to the button but it seems to have resolved it self after I removed the duplicate.