My PhotosListCollectionViewController.h file:
@interface PhotosListCollectionViewController : UICollectionViewController <UICollectionViewDelegateFlowLayout> {
FooterView *footerView;
PhotosListCollectionViewViewModel *photosListCollectionViewViewModel;
}
@property (strong, nonatomic) NSString *userQuery;
@end
In PhotosListCollectionViewController.m (look comment):
@implementation PhotosListCollectionViewController
- (void)viewDidLoad {
[super viewDidLoad];
footerView = [[FooterView alloc] init];
photosListCollectionViewViewModel = [[PhotosListCollectionViewViewModel alloc] initWithUserQuery:_userQuery];
[self.collectionView registerClass:FooterView.class forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:NSStringFromClass([FooterView class])];
__weak __typeof(self)weakSelf = self;
photosListCollectionViewViewModel.getNextPage = ^(NSError *error) {
if (nil == error) {
[weakSelf.collectionView reloadData];
} else {
[weakSelf showAlertWithTitle:error.localizedDescription message:@"Try again."];
}
[self->footerView hideLoader]; // warning in this line.
};
}
How to resolve my problem? I read another questions, but they did not solve my problem.
Change to
[weakSelf->footerView hideLoader];
get error
Dereferencing a __weak pointer is not allowed due to possible null value caused by race condition, assign it to strong variable first