I have my instance variable declaration:
@interface TimelineTableViewController ()
@property (strong, nonatomic) NSMutableArray *avatars;
@end
And then my block:
void UIImageFromURL(NSURL *URL, NSString *key, void(^imageBlock)(UIImage *image), void(^errorBlock)(void)) {
    dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
        NSData  *data  = [[NSData alloc] initWithContentsOfURL:URL];
        UIImage *image = [[UIImage alloc] initWithData:data];
        dispatch_async( dispatch_get_main_queue(), ^(void){
            if (image != nil) {
                [self.avatars setObject:image forKey:key];
                NSLog(@"%@", self.avatars);
                imageBlock( image );
            } else {
                errorBlock();
            }
        });
    });
}
What I'm trying to do, is cache the downloaded image to an instance array to avoid re-downloading every the TableCell get's recreated. However, I get the error:
Use of undeclared identifier 'self'
I call my block like so, if that helps:
- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TweetCell *cell = (TweetCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    NSDictionary *tweetObject = _tweets[indexPath.row];
    NSDictionary *userObject = tweetObject[@"user"];
    NSString *avatarURL = userObject[@"profile_image_url"];
    avatarURL = [avatarURL stringByReplacingOccurrencesOfString:@"_normal"
                                                     withString:@""];
    NSURL *imageURL = [NSURL URLWithString:avatarURL];
    UIImageFromURL(imageURL, avatarURL, ^(UIImage *image) {
        [cell.avatarImage setImage:image];
    }, ^{
        NSLog(@"Failed to fetch profile picture.");
    });
    return cell;
}
 
     
     
     
    