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
in parse.com dashboard showing this
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:
- query
pfobject
in question - use
-[pffile getdatainbackgroundwithblock:]
retrievepffile
's data create
uiimage
resultingnsdata
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
Post a Comment