0

I´m new at programming and I get an error that I wasn´t able to solve yet, even the question didn´t help me: What does “fatal error: unexpectedly found nil while unwrapping an Optional value” mean?

Here is the error:

fatal error: unexpectedly found nil while unwrapping an Optional value 2017-10-27 18:30:48.283483+0200 Inspireme1.0[1149:631849] fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

Here is my code:

var quotes: RandomItems! = RandomItems([

"Jonas",
"Mary",
"Michael",
"Jeff",                 
"Sarah",

])

@IBAction func PresentText(_ sender: Any) {

PresentingLabel.text = quotes.next() //<-- Error

}

var randomItems: RandomItems?


override func viewDidAppear(_ animated: Bool) {
// Code to load the struct again after the view appears.
let defaults = UserDefaults.standard
quotes = defaults.codable(RandomItems.self, forKey: "quotes")
}

override func viewWillDisappear(_ animated: Bool) {
// Code to save struct before the view disappears.
let defaults = UserDefaults.standard
if let quotes = quotes {
    defaults.set(codable: quotes, forKey: "quotes")
}
}
Jay23
  • 57
  • 7
  • Please don't repost your questions. If needed, edit your previous question. – rmaddy Oct 27 '17 at 16:52
  • @DávidPásztor no it´s not a duplicate. I´ve already said that I didn´t found a solution there. I wrote this in my question. – Jay23 Oct 27 '17 at 16:54
  • 1
    You've posted the same code with the same error message as the question you posted an hour ago. How is it not the same? – rmaddy Oct 27 '17 at 16:56

0 Answers0