0

Url :- https://newdrcom.azurewebsites.net/DoctorsList.aspx

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = doctorsTableView.dequeueReusableCell(withIdentifier: "DoctorTableViewcellTableViewCell", for: indexPath) as! DoctorTableViewcellTableViewCell
        let doctor = doctorData[indexPath.row]

        cell.doctorname.text = doctor.name
        cell.doctorDepartment.text = doctor.department
        cell.doctorspeclization.text = doctor.specialization
        cell.hospitalName.text = doctor.hospital
//        cell.doctorimg.image = UIImage(named: doctor.picture ?? "")
        guard let receivedImage = try? Data(contentsOf: URL(string: doctorData[indexPath.row].picture ?? "")!) else {
            
            return cell
        }
        cell.doctorimg.image = UIImage(data: receivedImage)
        return cell
        }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 360
    }
}

Getting this error :-

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Synchronous URL loading of http://flspinalsurgeon.com/wp-content/uploads/2016/06/704ef3f5ca13ed331b597014a1f3fe7a_400x400.jpeg should not occur on this application's main thread as it may lead to UI unresponsiveness. Please switch to an asynchronous networking API such as URLSession.

Joakim Danielson
  • 43,251
  • 5
  • 22
  • 52
  • 2
    Like the warning says, don't use a synchronous call when downloading data from a remote server. Learn about using URLSession or perhaps in this case AsyncImage. – Joakim Danielson Jul 08 '23 at 12:44
  • `.picture ?? ""`, validate that you have a proper url before you try to download anything. "" is not a proper url. – Joakim Danielson Jul 08 '23 at 12:48

0 Answers0