Fatal Error Message (PLEASE HELP!)

Hi,

I was recently doing the War Card Game tutorial. I followed everything that Chris did, but on the “How To Make Your First App”, at around the 3:01:00 time stamp, Chris clicked the Deal button. For some reason, when I did the exact same thing, my app crashed and an error message came up saying (in the editor itself):
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

The console said the same thing, but at the end, it said “Optional Value: File”.

I tried debugging, but don’t know what to do. I have the same image assets as Chris, but still, it doesn’t work.

Please help so I can move on and finish my War Game, which I am looking forward to doing. Attached is an image of the editor, console, and terminal.
Thank you,

A student

Editor, console, and terminal:

Welcome!

Do you have the card assets copied to your Assets folder?

If not you will get a nil error because xcode can’t find your “card5” image asset.

Blessings,
—Mark

1 Like

Hi Mark,

The card assets are in the assets folder. Here is a screenshot of Xcode.

I expect it is nil because of the folder in the path name. Rather than drag the folder into the assets, drag just the cards so they are not inside a folder.

I could be wrong, but that is a good first try.

Blessings,
—Mark

1 Like

Hi,

Unfortunately, that still didn’t work :frowning:. My assets folder looks like this.


Any thoughts on the error saying it was unwrapping an optional value called file?

It also says, in green font, at the bottom of the error message in the terminal output: (11db). Not sure if that helps.

Thanks,

YourAvgCoder

I also tried changing the image being used, and even tried uploading my own images to see if they would work. Nothing changed, same error message.

I really appreciate all the help…

Is the @IBAction connected to the button OK? Right click on the button to ensure there is a connection. You can also check to ensure the card image Target Membership is connected. xcassets%202019-10-28%2020-33-11

This one has me stumped.
Wiser, more experienced coders will chime in. Hang on…
Blessings,
—Mark

2 Likes

Oh my god! Thank you so much. You saved me so much time! :grinning:

I really appreciate all the great help you’ve given me! I followed the tutorial and remembeer connecting the buttons, but I could be wrong.

Thank you so much!

Let us know if you get it going again. Hope so!

Blessings,
—Mark

3 Likes

Thanks for helping Mark!!