0

Tell me how to get rid of the error in my method? has many options tried and still the image does not display on ViewContoller.

func detailObject() {
    let query = PFQuery(className: "soccer")
    query.findObjectsInBackground { (objects:[PFObject]?, error:Error?) in
        if error == nil {
            for objects in objects! {
                let detailPrognozS  = objects["detailPrognozS"] as! String
                let detailTitleS = objects["detailTitleS"] as! String
                let detailTextS = objects["detailTextS"] as! String
                let imageDetail = objects["detailImageS"] as? PFFile
                DispatchQueue.main.async { [unowned self] in
                    self.prognozDetail.text = detailPrognozS
                    self.textView.text = detailTextS
                    self.titleDetail.text = detailTitleS
                }
                imageDetail?.getDataInBackground(block: { (data:Data?, error:Error?) in
                    if error == nil {
                        if let imageData = data {
                            DispatchQueue.main.async { [unowned self] in
                                self.imageDetail.image = UIImage(data: imageData)
                            }
                        }
                    }
                })
            }
        }
}

The code displays this error:

Fatal error: unexpectedly found nil while unwrapping an Optional value Error be in this line"self.imageDetail.image = UIImage(data: imageData)" and the app crashes...please tell me.I beg you...

  • Try to reconnect the outlet of your imageView – Salman Ghumsani Oct 03 '17 at 14:32
  • I have a Parse ? does not display the image and emboss in the specified line in my question.. – Aleksandr Ilin Oct 03 '17 at 14:33
  • It seems like your imageView is nil. – Salman Ghumsani Oct 03 '17 at 14:36
  • Also, you can use the answer https://stackoverflow.com/questions/46199203/downloading-uiimage-via-alamofireimage/46199246#46199246 – Salman Ghumsani Oct 03 '17 at 14:37
  • Yes , but how to get rid of.Can more to tell.And then three options I've tried here and found the answers.And confused.And I practice zero.I am very grateful – Aleksandr Ilin Oct 03 '17 at 14:40
  • https://www.google.co.in/search?q=connect+the+outlet+swift&safe=active&rlz=1C5CHFA_enIN719IN719&tbm=isch&imgil=JFIRh8-h_YAG9M%253A%253BGjajkFg4iXdp6M%253Bhttps%25253A%25252F%25252Fdevelopers.arcgis.com%25252Fios%25252Flatest%25252Fswift%25252Fguide%25252Fdevelop-your-first-map-app.htm&source=iu&pf=m&fir=JFIRh8-h_YAG9M%253A%252CGjajkFg4iXdp6M%252C_&usg=__5FUo11nEQAF9xMSBrKfxHpS9r8c%3D&biw=1280&bih=612&ved=0ahUKEwjSjb7119TWAhXMLI8KHcWvC2gQyjcITg&ei=vaHTWZK7BczZvATF367ABg#imgrc=f72kcwMJZOS9IM: – Salman Ghumsani Oct 03 '17 at 14:43
  • I have here that displays the scoreboard,"imageDetail PFFile? 0x000060400044b580", this method I know and I have it fixed. – Aleksandr Ilin Oct 03 '17 at 14:50

0 Answers0