objective c - How to retrive image from parse.com -


hi new using parse.com iam trying save image in parse.com , retriving it.. saved image pffile enter image description here

in parse.com dashboard showing this

enter image description here

now how can retrive image , show in uiimageview

i tryied not working..

 pfquery *query = [pfquery querywithclassname:@"userphoto"];     [query wherekey:@"username" containsstring:@"ravi"];     [query getobjectinbackgroundwithid:@"id" block:^(pfobject *object, nserror *error) {         if(!error){             pffile *im = [object objectforkey:@"imagefile"];             _getimg.image = im;         }}]; 

here want retrive particular image of username ravi

thanks in advance.. :)

to retrieve image, need to:

  1. query pfobject in question
  2. use -[pffile getdatainbackgroundwithblock:] retrieve pffile's data
  3. create uiimage resulting nsdata

    pfquery *query = [pfquery querywithclassname:@"userphoto"];  [query wherekey:@"username" containsstring:@"ravi"];  [query getfirstobjectinbackgroundwithblock:^(pfobject *object, nserror *error) {     if (!object) {         return nslog(@"%@", error);     }      pffile *imagefile = object[@"imagefile"];      [imagefile getdatainbackgroundwithblock:^(nsdata *data, nserror *error) {         if (!data) {             return nslog(@"%@", error);         }          // image         self.imageview.image = [uiimage imagewithdata:data];     }]; }]; 

as aside, unless purely experimentation, or you're performing operation off of main thread, avoid saving pfobject synchronously using -[pfobject save] , use instead, asynchronous version, -[pfobject saveinbackgroundwithblock:].


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -