Hi,
I wish to remotely load some data before I initialise the collection view. I read somewhere one way to do this is to only set the delegate and datasource after I loaded the data.
However I'm setting the error
"UICollectionView.delegate must be used from main thread only"
next to the line
self.myCollectionView.delegate = self
I suppose this is not the best way to do this. What is the recommended way?
Cheers Richard
Where do you call this ?
self.myCollectionView.delegate = self
I don't know if it is the correct solution, but to avoid error, you should call from the main thread:
DispatchQueue.main.async {
self.myCollectionView.delegate = self
}
Another way would be to hide the collectionView at start and unhide only when data are loaded (in the completion handler of load() )