Swift 3: cant get image from Parse? -
ok, have looked @ questions how access object's fields parse query result in swift? answer not working in swift 3. following trying image first pfobject in parse error:
cannot convert value type nsdata, nserror -> void expected pfdataresultblock ?
var query = pfquery(classname: parse_class!) query.order(bydescending: "createdat") query.findobjectsinbackground { (objects, error) -> void in if error == nil { //print(objects?.first?["testtxt"] as! nsstring) //print(objects?.first?["testimg"] as! pffile) let thumbnail = objects?.first?["testimg"] as! pffile thumbnail.getdatainbackgroundwithblock{(imagedata: nsdata?, error: nserror?) -> void in if error == nil { if let image = uiimage(data: imagedata!) { //get image here } } } }
i have tried changing type , everything. how can store image parse in recent swift?
you can try this:
if let validobjects = objects { object in validobjects { let thumbnail = object["testimg"] as? pffile thumbnail?.getdatainbackground (block: { (data, error) -> void in //read image here } } }
Comments
Post a Comment