Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Simple iPhone App with Swift Improving Our User Interface Finishing Up Our Layout

Aaryen Singh
Aaryen Singh
1,688 Points

I'm getting a strange error when I run the app. Please help!!!

When I run the app, it says that the build has succeeded and then loads the app. A second later, it closes the app and gives an error in the following code:

import UIKit

class ViewController: UIViewController {

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

override func viewDidLoad() {

    funFactsLabel.text = factProvider.randomFact() \\Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value (the error)

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

} }


Can you show the implementation of the "randomFact()" method ?

2 Answers

Aaryen Singh
Aaryen Singh
1,688 Points

Hi Jhoan,

Thank you for replying however I'm not sure what you mean by implementation. Could you please explain clearer as I'm still kind of new to this?

Sorry about the delay for the answer: I was on holiday

Hope to see your response.

Hey, I apologize, I just got back from vacation..

Are you still having this issue?

"Implementation" is the process of "making" something.. When you "implement" a method, means that you have created or designed a function to do something.

Aaryen Singh
Aaryen Singh
1,688 Points

No, I managed to figure it out but thanks anyway.

thx again Aaryen