From 5212d022ab1e3c568b99220e33eff3ccdc1645ed Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Thu, 10 Jan 2019 08:56:38 +0100 Subject: [PATCH] Fix loading items in ASDKGram IGListKit example (#1300) --- .../ASDKgram/Sample/PhotoFeedSectionController.m | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/ASDKgram/Sample/PhotoFeedSectionController.m b/examples/ASDKgram/Sample/PhotoFeedSectionController.m index b621b0252..87cce316f 100644 --- a/examples/ASDKgram/Sample/PhotoFeedSectionController.m +++ b/examples/ASDKgram/Sample/PhotoFeedSectionController.m @@ -82,12 +82,15 @@ - (void)beginBatchFetchWithContext:(ASBatchContext *)context [self setItems:newItems animated:NO completion:nil]; } - // Start the fetch, then update the items (removing the spinner) when they are loaded. - [_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){ - [self setItems:_photoFeed.photos animated:NO completion:^{ - [context completeBatchFetching:YES]; - }]; - } numResultsToReturn:20]; + // Push to next runloop to give time to insert the spinner + dispatch_async(dispatch_get_main_queue(), ^{ + // Start the fetch, then update the items (removing the spinner) when they are loaded. + [_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){ + [self setItems:_photoFeed.photos animated:NO completion:^{ + [context completeBatchFetching:YES]; + }]; + } numResultsToReturn:20]; + }); }); }