Last active
August 29, 2015 14:05
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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