so i'm fairly new to Xcode and C# so this may be a silly question, but none-the-less it has had me tearing my hair out for 3 days now.
Ok, so I am using Parse to fetch and save data, images, etc. I want to display a UITableView with the PFFile images. This bit I have managed.
The issue I have is the the scrolling performance is bad because i'm not caching the PFFile images that come in. I have no idea how to do this and any searches i make don't take into account using parse.
below is my code that puts the initial data into an array:
-(void) retrieveFromParse {
PFQuery *retrieveContent = [PFQuery queryWithClassName:@"NewsFeed"];
[retrieveContent orderByDescending:@"createdAt"];
//[retrieveContent unpinInBackground];
//retrieveContent.cachePolicy = kPFCachePolicyCacheElseNetwork;
[retrieveContent findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if(!error){
mainArray = [[NSArray alloc] initWithArray:objects];
}
[tableView reloadData];
}];
}
This code then gets the images:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"MyCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.profilePicture.layer.cornerRadius = cell.profilePicture.frame.size.height /1.99;
cell.profilePicture.layer.masksToBounds = YES;
cell.profilePicture.layer.borderWidth = 0;
PFObject *imageObject = [mainArray objectAtIndex:indexPath.row];
PFFile *imageFile = [imageObject objectForKey:@"image"];
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if(!error){
NSLog(@"%@",data);
cell.myImage.image = [UIImage imageWithData:data];
}
}];
return cell;
}
Now, you'll see i have commented out the cachePolicy because every time i use it, the thread breaks.
If someone could please alter my code or provide me with an example project using my code, to take into account caching either array and/or PFFile images, that would save me from going bald! :)
Many thanks in advance.