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

iOS

what 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.

Can you post your code, please?

Thanks,

Steve.

Steve hunter: I wish I could but Its in xcode and can't paste my screen shot

You can select your code then Cmd+C in Xcode and Cmd+V into the post on here.

K

class 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

I'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.

that fixed it but it created another error that says under // Do any aditional setup... expected decleration.

dont worry i sorted that last one. Thanks for the help!

Awesome - good work! :-)