ios - Setting parse images to a tableView Cell -


i'm trying save images parse variable called image stored can set tableview cells. @ moment have images parse being saved pfimageview. when try set these table view cells error : cannot assign value of type 'pfimageview' type 'uiimage?' . appreciate help.

here's code:

import uikit import parse import bolts import parseui  class yourevents: uiviewcontroller, uitableviewdatasource, uitableviewdelegate {      @iboutlet weak var tableview: uitableview!     var currentuser = pfuser.currentuser()?.username       //array     var testarray = [string]()      var testdecr = [string]()     var image = uiimage()       var imagestored = pfimageview()      override func viewdidload() {         super.viewdidload()         var query = pfquery(classname:"companies")          let pusername = pfuser.currentuser()?["username"] as? string          query.wherekey("createdby", equalto:"\(pusername)")         // let runkey = query.orderbyascending("companyname")         query.findobjectsinbackgroundwithblock{             (objects: [pfobject]?, error: nserror?) -> void in              if error == nil {                 //do found objects                 if let objects = objects [pfobject]! {                     object in objects {                          let load = object.objectforkey("companyname") as! string                         self.testarray .append(load)                          print(self.testarray)                          let load2 = object.objectforkey("companydescription") as! string                         self.testdecr.append(load2)                          print(self.testdecr)                           if let userimagefile = object["imagefile"] as? pffile {                          userimagefile.getdatainbackgroundwithblock {                             (imagedata: nsdata?, error: nserror?) -> void in                             if error == nil {                                 if let imagedata = imagedata {                                      self.image = uiimage(data:imagedata)!                                 }                             }                         }                      }                           }                  }             } else {                 //log details of failure                 print("error: \(error!) \(error?.userinfo) ")              }           }          // reload  uiviewcontroller , uitabkeview         sleep(3)          do_table_refresh()     }      func do_table_refresh () {         dispatch_async(dispatch_get_main_queue(),  {             self.tableview.reloaddata()             return         })     }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }        func numberofsectionsintableview(tableview: uitableview) -> int {         return 1     }      func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {         return testarray.count     }      func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let cell = tableview.dequeuereusablecellwithidentifier("yourstartups", forindexpath: indexpath) as! yourstartupscell         cell.lbtitle!.text = self.testarray[indexpath.row]         cell.lbdescription!.text = self.testdecr[indexpath.row]         cell.logo!.image = self.imagestored            return cell     }  } 

the error

in code never initialize imagestored (pfimageview) image (uiimage). try change in

cell.logo!.image = self.image 

i no have idea if pfimageview has

pfimageview.image 

instances, should uiimage() class.

also should have this:

 if let userimagefile = object["imagefile"] as? pffile {                      userimagefile.getdatainbackgroundwithblock {                         (imagedata: nsdata?, error: nserror?) -> void in                         if error == nil {                             if let imagedata = imagedata {                                  self.image = uiimage(data:imagedata)!                                   var img = uiimage(data:imagedata)                                  image.append(img)                                  self.tableview.reloaddata()                             }                         }                     } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -