Skip to content

Instantly share code, notes, and snippets.

@vikdenic
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save vikdenic/b0acbe9bd44cce56a170 to your computer and use it in GitHub Desktop.

Select an option

Save vikdenic/b0acbe9bd44cce56a170 to your computer and use it in GitHub Desktop.
retrieving image files from parse, converting them to images, and adding them in an array
@property NSMutableArray *self.shoeImagesArray;
// ^somewhere within your interface
-(void)retrieveImagesFromParse
{
self.shoeImagesArray = [NSMutableArray new];
PFQuery *query = [PFQuery queryWithClassName:@“Shoe”];
[query findObjectsInBackgroundWithBlock:^(NSArray *shoeObjects, NSError *error)
{
if (!error)
{
for (PFObject *shoeObject in shoeObjects)
{
PFFile *shoeImageFile = [shoeObject objectForKey:@“ShoePhoto”];
[shoeImageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error)
{
if(!error)
{
UIImage *image = [UIImage imageWithData:data];
self.shoeImagesArray = image;
[self.tableView reloadData];
}
}
}
}
}
}
//Then in cellForRowAtIndexPath, do the following: cell.imageView.image = [self.shoeImagesArray objectAtIndex: indexPath.row];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment