database - Parse.com load Image in Uiimage Swift -


i've searched on internet can't find sensible answer question. want load image stored in parse database (not user based) in advance i'm new this.

code tried:

    var query = pfquery(classname:"movies")     query.wherekey("indexid", equalto:strrandomid)     query.findobjectsinbackgroundwithblock         {             (objects: [anyobject]?, error: nserror?) -> void in          if error == nil {             // find succeeded.             println("successfully retrieved \(objects!.count) objects.")             println("randomid = \(strrandomid) ")              // found objects               if let objects = objects as? [pfobject]             {                 parsedata in objects                 {                     println(parsedata.objectid)                     self.lbltitle.text = string(stringinterpolationsegment: parsedata["moviename"]!)                     self.lblyear.text = string(stringinterpolationsegment: parsedata["year"]!)                     self.lblrating.text = string(format: "%.1f", float_t(parsedata["imdb_rating"]! as! nsnumber))                     self.lbldescription.text = string(stringinterpolationsegment: parsedata["plot"]!)                      let image = parsedata["poster"] as! pffile                     image.getdatainbackgroundwithblock                     ({                         (imagedata: nsdata!, error: nserror!) -> void in                         if (error == nil)                         {                             let imgposter = uiimage(data: imagedata)                         }                     })                 }             }         }          else         {             // log details of failure             println("error: \(error!) \(error!.userinfo!)")         }     } 

okay fixed it:

        if error == nil {             // find succeeded.             println("successfully retrieved \(objects!.count) objects.")             println("randomid = \(strrandomid) ")               // found objects              object: anyobject in objects!             {                 let poster = object["poster"] as! pffile                 poster.getdatainbackgroundwithblock({                     (imagedata: nsdata?, error: nserror?) -> void in                     if (error == nil)                     {                          var blur = uiblureffect(style: uiblureffectstyle.light)                         var blurview = uivisualeffectview(effect: blur)                         let image = uiimage(data: imagedata!)                         self.imgbackground.image = image                         self.imgposter.image = image                         blurview.frame = self.imgbackground.bounds                         self.imgbackground.addsubview(blurview)                      }                 })              }               if let objects = objects as? [pfobject]             {                 parsedata in objects                 {                     println(parsedata.objectid)                     self.lbltitle.text = string(stringinterpolationsegment: parsedata["moviename"]!)                     self.lblyear.text = string(stringinterpolationsegment: parsedata["year"]!)                     self.lblrating.text = string(format: "%.1f", float_t(parsedata["imdb_rating"]! as! nsnumber))                     self.lbldescription.text = string(stringinterpolationsegment: parsedata["plot"]!)                   }             }          } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -