Have an issue when sending the imageURL to anotherViewController the error is like ( Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value).I'm using messageKit and SdWEbImage pod.When user click on image it goes to photoViewController and image will show.
ChatDashobard Controller:
extension ChatDashboard:MessageCellDelegate{
// MARK:- Working only for image
func didTapImage(in cell: MessageCollectionViewCell) {
guard let indexPath = messagesCollectionView.indexPath(for: cell) else {return}
self.configureImageVeiwController(messagesData: self.messages[indexPath.section])
}
func configureImageVeiwController(messagesData:Message){
let messages = messagesData.kind
switch messages {
case .photo(let media):
guard let imageURL = media.url else {
return
}
let photoCotroller = PhotoViewController()
photoCotroller.imageUrL = imageURL
self.navigationController?.pushViewController(photoCotroller, animated: true)
default:
break
}
}
}
PhotoViewController:
@IBOutlet weak var productImage: UIImageView!
var imageUrL:URL? = nil
override func viewDidLoad() {
if let getImageFromURL = imageUrL{
productImage.sd_setImage(with:getImageFromURL,completed:nil)
}
}