Shawn
Shawn

Reputation: 667

Reload collection view with new data

How would I reload new data, say an array of names (strings), without re initializing the collection view with data?

I know of [uiCollectionView reloadData], but I wanted to changed the array of information associated with the collection view.

Upvotes: 2

Views: 4434

Answers (1)

Wain
Wain

Reputation: 119031

reloadData causes the collection view to ask its dataSource about what it now contains. Whatever the dataSource uses to decide, this is your collection view source data. If you change that data then you need to call reloadData for your UI to get updated. You can change the data however you want (like adding / removing items from the array or creating an entirely new array).

You never initialise the collection view with data. You initialise it with a delegate and dataSource. So you aren't re-initialising it. You're just changing the data that the dataSource is providing to the collection view.

Upvotes: 3

Related Questions