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() {
    super.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()

} }

Jhoan Arango
Jhoan Arango
Treehouse Moderator 13,603 Points

Hello,

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.

Jhoan Arango
Jhoan Arango
Treehouse Moderator 13,603 Points

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