If you look in the console in your image you can see the text fatal error: unexpectedly found nil while unwrapping an Optional value
That means that you are trying to do something (unwrap the value in this case) with an object that is nil.
If you look at the line highlighted with red in your image, then that is where the crash occurred. You can see that you are trying to set the value of your detailsLabel.text
to currentPic!.notes
Your currentPic
is a Photo?
, question mark meaning Optional
, Optional
meaning: it can be something or it can be nothing. The !
in currentPic!.notes
means that you are telling the compiler to just unwrap the optional, nil value or no nil value. This is normally a bad thing to do, because, as you can see here, if it is nil, then you receive a crash when for instance you try to use nil to set the text
of a UILabel
.
So, a couple of things for you to check.
- is your
detailsLabel
connected properly to an Outlet (it seems so based on your image, but...you know, better safe than sorry :-))
Try unwrapping currentPic safely:
if let currentPic = currentPic {
detailsLabel.text = currentPic.notes
}
- If safe unwrapping works, then you could start looking at why your
currentPic
variable is nil. It should probably be initialised with some value before you start using it in viewDidLoad()
, maybe it should be sent along when you navigate from one page to another. In any case, you need to initialise it to something before you try to use it in viewDidLoad()
Hope that helps you.