ios - Fetching data from Parse.com into custom cell (swift) -
i attempting fetch data parse.com custom cell full of strings , images. believe either retrieving pffile incorrectly parse.com or retrieving pffile correctly converting file uiimage improperly. error receiving going on within loaddata() function. reads follows: could not find overload 'init' accepts supplied arguments
information
//used set custom cell class information { var partyname = "" var promotername = "" var partycost = "" var flyerimage: uiimage var promoterimage: uiimage init(partyname: string, promotername: string, partycost: string, flyerimage: uiimage, promoterimage: uiimage) { self.partyname = partyname self.promotername = promotername self.partycost = partycost self.flyerimage = flyerimage self.promoterimage = promoterimage } }
parse fetch function
func loaddata() { var finddataparse:pfquery = pfquery(classname: "flyerdatafetch") finddataparse.findobjectsinbackgroundwithblock{ (objects: [anyobject]?, error: nserror?) -> void in if (error == nil) { object in objects! { var eventimage0 : uiimage var eventimage10 : uiimage let userimagefile = object["partyflyerimage"] as! pffile userimagefile.getdatainbackgroundwithblock { (imagedata: nsdata?, error: nserror?) -> void in if error == nil { let eventimage = uiimage(data:imagedata!) eventimage0 = eventimage! } } let userimagefile1 = object["partypromoterimage"] as! pffile userimagefile1.getdatainbackgroundwithblock { (imagedata1: nsdata?, error1: nserror?) -> void in if error1 == nil { let eventimage1 = uiimage(data:imagedata1!) eventimage10 = eventimage1! } } //error below var party1 = information(partyname: (object["partyname"] as? string)!, promotername: (object["partypromotername"] as? string)!,partycost: (object["partycost"] as? string)!, flyerimage: uiimage(data: eventimage0)!, promoterimage: uiimage(data: eventimage10)!) self.arrayofparties.append(party1) } } self.tableview.reloaddata() } }
you fetching data parse in background, processing on main thread. try this:
func loaddata() { var finddataparse:pfquery = pfquery(classname: "flyerdatafetch") finddataparse.findobjectsinbackgroundwithblock{ (objects: [anyobject]?, error: nserror?) -> void in if (error == nil) { object in objects! { var eventimage0 : uiimage var eventimage10 : uiimage let userimagefile = object["partyflyerimage"] as! pffile userimagefile.getdatainbackgroundwithblock { (imagedata: nsdata?, error: nserror?) -> void in if error == nil { let eventimage = uiimage(data:imagedata!) eventimage0 = eventimage! let userimagefile1 = object["partypromoterimage"] as! pffile userimagefile1.getdatainbackgroundwithblock { (imagedata1: nsdata?, error1: nserror?) -> void in if error1 == nil { let eventimage1 = uiimage(data:imagedata1!) eventimage10 = eventimage1! var party1 = information(partyname: (object["partyname"] as? string)!, promotername: (object["partypromotername"] as? string)!, partycost: (object["partycost"] as? string)!, flyerimage: uiimage(data: eventimage0)!, promoterimage: uiimage(data: eventimage10)!) self.arrayofparties.append(party1) } } } } } } self.tableview.reloaddata() } }
Comments
Post a Comment