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

Xcode simulator 7.2 does not seem to work

Hi guys,

I have an issue with my xcode simulator, for the course "Build a simple iPhone app with Swift", we're creating this funFacts app.

The simulator works just fine there but when I click on the button to generate another fact it does not show one in the simulator as it is supposed to, it opens xcode again and goes straight to the debug navigator.

Does anybody know what I am supposed to do here?

Thanks in advance

Your app is crashing because of a runtime error. Can you show us your code?

3 Answers

I have the same problem

I can show the code

This is my FactsModel.swift

//
//  FactsModel.swift
//  FunFacts
//
//  Created by Arman on 14/03/16.
//  Copyright © 2016 Treehouse. All rights reserved.
//

struct FactModel {
    let facts = [
        "Ants stretch when they wake up in the morning.",
        "Ostriches can run faster than horses.",
        "Olympic gold medals are actually made mostly of silver.",
        "You are born with 300 bones; by the time you are an adult you will have 206.",
        "It takes about 8 minutes for light from the Sun to reach Earth.",
        "Some bamboo plants can grow almost a meter in just one day.",
        "The state of Florida is bigger than England.",
        "Some penguins can leap 2-3 meters out of the water.",
        "On average, it takes 66 days to form a new habit.",
        "Mammoths still walked the Earth when the Great Pyramid was being built." ]
}

And this is ViewController.swift

//
//  ViewController.swift
//  FunFacts
//
//  Created by Arman on 13/03/16.
//  Copyright © 2016 Treehouse. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var funFactLabel: UILabel!
    let factModel = factModel()

    override func viewDidLoad() {
        super.viewDidLoad()
        funFactLabel.text = factModel.facts[0]
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func showFunFact() {

        funFactLabel.text = factModel.facts[1]
    }

}

Actually I have an error in ViewController.swift on line 14

let factModel = factModel()

which says "Variable used within its own initial value"

Does anybody know what does it mean? Pasan's code is the same but he doesn't have an error and the simulator works fine

// Try capitalizing FactModel()
let factModel = FactModel()

Thank you. The error is gone. But the simulator still doesn't work properly. I only see white screen.