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 trial
aaron carrier
Courses Plus Student 1,001 Pointswhat is wrong with my swift code
i keep on getting an error message it tells me only instances can be decleard "IBAction" in xcode there is also an other message which says at the end of my code exprected decleration.
aaron carrier
Courses Plus Student 1,001 PointsSteve hunter: I wish I could but Its in xcode and can't paste my screen shot
Steve Hunter
57,712 PointsYou can select your code then Cmd+C in Xcode and Cmd+V into the post on here.
aaron carrier
Courses Plus Student 1,001 PointsK
aaron carrier
Courses Plus Student 1,001 Pointsclass ViewController: UIViewController {
@IBOutlet weak var funFactLabel: UILabel!
let factBook = FactBook()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
funFactLabel.text = factBook.factsArray[0]
} // <-- Needs a closing brace here
func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func showFunFact() {
funFactLabel.text = factBook.factsArray[1]
}
}
2 Answers
Steve Hunter
57,712 PointsI've added one comment - there's a } missing under viewDidLoad(). That might fix the problems - give it a go and let me know.
If it doesn't work - we can figure something else out!
Steve.
aaron carrier
Courses Plus Student 1,001 Pointsthat fixed it but it created another error that says under // Do any aditional setup... expected decleration.
aaron carrier
Courses Plus Student 1,001 Pointsdont worry i sorted that last one. Thanks for the help!
Steve Hunter
57,712 PointsAwesome - good work! :-)
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsCan you post your code, please?
Thanks,
Steve.