How to update CollectionView's numberOfItemsInSection after block finishes executing

daspianist

I would like to put up a UICollectionView of pictures downloaded from a backend provider, and am running the issue where every time my collection view controller is initialized, the required method

- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

always returns 0, despite my providing the code [self.profilePicturesStorage count]. I understand that because I am using a block to populate the self.profilePicturesStorage property, at the view initialization it will always return 0 (since the block hasn't finished executing) My question is, how do I update CollectionView's numberOfItemsInSection: method after my block has finished downloading all the pictures?

This is the block that I execute in viewDidLoad:

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error){
            if ([objects count] > 0){
                //... Skip additional code that parse out the downloaded objects
                [self.profilePicturesStorage addObject:userPicture];
                }
            }
            else {
                NSLog(@"There aren't any pictures for the current user");
            }
        }
    }];

Thanks!

bneely

[collectionView reloadData] should be all you need.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to update CollectionView's numberOfItemsInSection after block finishes executing

From Dev

How to return numberOfItemsInSection for two collectionView?

From Dev

How to read in a user's input in shell script and replace a line with the input after the script finishes executing?

From Dev

UICollectionView not recognized in collectionView numberOfItemsInSection:

From Dev

collectionView:numberOfItemsInSection: in UITableviewcell (DetailedCell)

From Dev

CollectionView numberOfItemsInSection variable

From Dev

Is there an event fired right after a command finishes executing?

From Dev

update Fragment after AsyncTask finishes

From Dev

Swift: block all code until a function finishes executing

From Dev

dispatch_async never finishes executing entire block

From Dev

When block finishes executing, ruby interpreter does not continue to next instruction

From Dev

Run code only after asynchronous function finishes executing

From Dev

Is the local byte buffer cleared after the method finishes executing?

From Dev

Code to keep the command window open after code finishes executing

From Dev

How to restart a python script after it finishes

From Dev

How to delete a file after vlc finishes playing it?

From Dev

Code in try block continues executing after exception?

From Dev

Why a block variable in scala function could not update after executed the inner block(s)?

From Dev

Update CollectionView´s size inside a UicollectionViewCell

From Dev

echo "." until command finishes executing

From Dev

K8s job memory consumption after job finishes

From Dev

How to update component's state after redirect?

From Dev

WPF How to update GUI when background thread finishes creating collections?

From Dev

How to do a page refresh after submitting and executing an update statement to show the updated values?

From Dev

how to write if else in the html td . if block and else block both are executing

From Dev

How to load template in angular after controller finishes loading parameters?

From Dev

How to display Toast from a Service after main Activity finishes?

From Dev

How to run a Grunt task after my Yeoman generator finishes installing?

From Dev

How to print the console to a text file AFTER the program finishes (Python)?

Related Related

  1. 1

    How to update CollectionView's numberOfItemsInSection after block finishes executing

  2. 2

    How to return numberOfItemsInSection for two collectionView?

  3. 3

    How to read in a user's input in shell script and replace a line with the input after the script finishes executing?

  4. 4

    UICollectionView not recognized in collectionView numberOfItemsInSection:

  5. 5

    collectionView:numberOfItemsInSection: in UITableviewcell (DetailedCell)

  6. 6

    CollectionView numberOfItemsInSection variable

  7. 7

    Is there an event fired right after a command finishes executing?

  8. 8

    update Fragment after AsyncTask finishes

  9. 9

    Swift: block all code until a function finishes executing

  10. 10

    dispatch_async never finishes executing entire block

  11. 11

    When block finishes executing, ruby interpreter does not continue to next instruction

  12. 12

    Run code only after asynchronous function finishes executing

  13. 13

    Is the local byte buffer cleared after the method finishes executing?

  14. 14

    Code to keep the command window open after code finishes executing

  15. 15

    How to restart a python script after it finishes

  16. 16

    How to delete a file after vlc finishes playing it?

  17. 17

    Code in try block continues executing after exception?

  18. 18

    Why a block variable in scala function could not update after executed the inner block(s)?

  19. 19

    Update CollectionView´s size inside a UicollectionViewCell

  20. 20

    echo "." until command finishes executing

  21. 21

    K8s job memory consumption after job finishes

  22. 22

    How to update component's state after redirect?

  23. 23

    WPF How to update GUI when background thread finishes creating collections?

  24. 24

    How to do a page refresh after submitting and executing an update statement to show the updated values?

  25. 25

    how to write if else in the html td . if block and else block both are executing

  26. 26

    How to load template in angular after controller finishes loading parameters?

  27. 27

    How to display Toast from a Service after main Activity finishes?

  28. 28

    How to run a Grunt task after my Yeoman generator finishes installing?

  29. 29

    How to print the console to a text file AFTER the program finishes (Python)?

HotTag

Archive