For an iOS application wherein a UIViewController
has a collectionView
whose datasource (an NSArray) is contained in a separate model class. This array is getting updated [adding / removing items to it] through an NSNotification
which in turn requires a web API call [on another thread]. When web service returns information then the datasource is updated and so also UICollectionView
needs to be updated. This process is continuous & occurs at random times.
The question is how the UICollectionView's
UI updation can be done in a safe manner so that it do not result in issues where UICollectionView
start complaining that no. of rows / section before update is not same as after update
Can anybody suggest an approach so that multithreading do not have any impact on UICollectionView
and one can safely use UICollectionView's
various UI manipulation api like insertSections, insertItemsAtIndexPath etc. In this process the UICollectionView
is continuously changing and so also its data source.