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 Build a Simple iPhone App with Swift Structs As Data Models Finishing Up Our Model

Ádám Csányi
PLUS
Ádám Csányi
Courses Plus Student 2,833 Points

My App keeps crashing, help needed :D

I was not able to post a picture of my code that I have written. So I will just copy paste it in here. Thanks for everyone for the answers and help in advance :D

ViewController.swift: // // ViewController.swift // MackoCrewFunFact // // Created by Adam Csanyi on 2017. 07. 31.. // Copyright © 2017. Csányi Ádám. All rights reserved. //

import UIKit

class ViewController: UIViewController {

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

override func viewDidLoad() {
    super.viewDidLoad()

    funFactLabel.text = factProvider.randomFact()

}

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

@IBAction func showFact() {
    funFactLabel.text = factProvider.randomFact()
}

}

FactProvider.swift: // // factProvider.swift // MackoCrewFunFact // // Created by Adam Csanyi on 2017. 08. 03.. // Copyright © 2017. Csányi Ádám. All rights reserved. //

import GameKit

struct FactProvider { let facts = [ "Gedének herpeszes volt a fasza", "Dani össze szarta a medencénket", "Jacqueline szeret pénzt bugázni a Balaton Soundon", "Farkas Dávid tengeri beteg", "Bence csak akkor pipázik ha van egy lány vele", "Ádámrol nincsenek ilyen gáz dolgok, ő teljesen rendbe van", "Csak a Volvo", "Szar a BMW meg az Audi is", "CK szeret szembe bemenni a körforgalomba és tele baszni egy embert akit megelőzőtt", "Gede szeret haza menni 24 óraval mindeki elött", "Gede szeret koktélt inni 550 euroért"]

func randomFact() -> String {
    let randomNumber = GKRandomSource.sharedRandom().nextInt(upperBound: facts.count)
    return facts[randomNumber]
}

}

Ádám Csányi
Ádám Csányi
Courses Plus Student 2,833 Points

the let randomNumber = GKRandomSource.sharedRandom().nextInt(upperBound: facts.count) is highlighted in green, and on the right side it says "Thread 1: Breakpoint 1.1". I hope this helps :D Chris Stromberg

1 Answer

Chris Stromberg
PLUS
Chris Stromberg
Courses Plus Student 13,389 Points

It looks like you've set a breakpoint. If you're not sure what those are or what they do you should look here:

http://jeffreysambells.com/2014/01/14/using-breakpoints-in-xcode

For now you can press CMD(?)+7 to select all breakpoints in Xcode. In the breakpoint navigator on the left you can now select and delete your breakpoints by pressing the backspace button. You can also select upon the blue arrow break points that show up on the left side of your gutter/line numbers and drag them away to delete them.