ios - Swift - Getting double ?? error when working with UIImage -


i having trouble working images parse. have created function take image files parse class, , save them dictionary (with key value being objectid). idea why and/or how fix? below codes:

  private func generatedictionaryofimages(imagekeytolookup: string, dictionarykeytoreturn: string) {      object in objectlist {       var currentobjectid = object.objectid!       var image = uiimage()        let imagefile = object[imagekeytolookup] as! pffile        imagefile.getdatainbackgroundwithblock({ (data: nsdata?, error: nserror?) -> void in          if data != nil {           if let imagedata = data {             image = uiimage(data: imagedata)!           }          }       }) // imagedictionary copied downloadedclientimages variable separately       self.imagedictionary[currentobjectid] = image     }   }    func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {      let cell = tableview.dequeuereusablecellwithidentifier("profile") as! profiletableviewcell      let title: string = grandcentral.returnvalueforkeyatindexpath(indexpath.row, key: "forename") as! string     let currentuserid: string = grandcentral.returncurrentuserid()  // error generated here. '@lvalue uiimage??' not convertible 'uiimage'     let image: uiimage = downloadedclientimages[currentuserid]     cell.setcell(title, image: image)      return cell   } 

you need unwrap optional after access dictionary.

if let image = downloadedclientimages[currentuserid] {     cell.setcell(title, image: image) } 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -