I'm new to ios dev and i'm trying to develop my first app! :) so far so good... Now I'm trying to pass data from main controller to the item details view.
It seems i can't figure out what i'm doing wrong but i keep getting an error: "fatal error: unexpectedly found nil while unwrapping an Optional value"
now i understand that the value is not assigned but i don't understand why... here's my code:
 -------> MainVC
   struct  Ananlysys {
    var descrizione: String!
    var data: String!
    var immagine: String!
    var seganle: String!
    var oraUpload: String!
    var valuta: String!
}
var analysisList = [Ananlysys]()  
var alertsRef = FIRDatabase.database().reference().child("analisi")
override func viewDidLoad() {
    super.viewDidLoad()
    fetchDataFromDB()        
}
func fetchDataFromDB(){
    alertsRef.observe(.childAdded, with: { snapshot in
        if let dict = snapshot.value as? [String: AnyObject] {
            let descrizione = dict["descrizione"] as! String
            let data = dict["data"] as! String
            let stato = dict["stato"] as! String
            let immagine = dict["imageURL"] as! String
            let seganle = dict["segnale"] as! String
            let oraUpload = dict["oraupload"] as! String
            let valuta = dict["valuta"] as! String
            self.analysisList.insert(Ananlysys(descrizione: descrizione, 
                   data:data, immagine:immagine, seganle: seganle, oraUpload: oraUpload, 
                   valuta: valuta), at: 0)
            self.tableView.reloadData()
        }
    })
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if segue.identifier == "ItemDetailVC"{
        if let indexPath = self.tableView.indexPathForSelectedRow {
            let destination = segue.destination as! ItemDetailVC
            let cell = tableView.cellForRow(at: indexPath) as? ItemCell
            destination.valuta = (cell?.valutaLabel.text)!
            destination.segnale = (cell?.signalLabel.text)!
            destination.desc = (cell?.descriptionLabel.text)!
            destination.immagine = (cell?.imageThumb.image)!
        }
    }
And in My ItemDetailsVC controller (which is the destination) i've just created the IBoutlet. Here' the code:
class ItemDetailVC: OpenAlertsVC {
    @IBOutlet weak var crossLabel: UILabel!
    @IBOutlet weak var signalLbl: UILabel!
    @IBOutlet weak var imageDetail: UIImageView!
    @IBOutlet weak var analysisDesc: UILabel!
  var valuta = ""
  var segnale = ""
  var immagine: UIImage!
  var desc = ""
}
override func viewDidLoad() {
    super.viewDidLoad()
      crossLabel.text = valuta
      signalLbl.text = segnale
      analysisDesc.text = desc
      imageDetail.image = immagine
}
Probably i'm just doing some stupid error... :) but it's my first app and i really don't know how to figure this out!
If anybody could help that would be much appreciate! :)
Thank you! Cheers!
UPDATE: I think my problems is because of the image. I have an url which i retrive from firebase in this way:
   let url = analysisList[indexPath.row].immagine
and then i download async the images:
   cell.imageThumb.downloadImageFrom(link: url!, contentMode: 
    UIViewContentMode.scaleToFill)
in the segue i do this:
   destination.immagine = (cell?.imageThumb.image)!
and in my DetailVC:
 var immagine: UIImage!
 imageDetail.image = immagine
this is the screen of the error enter image description here
 
     
    