cedric petetin cedric petetin - 8 months ago 32
Swift Question

Swift : collectionView takes too long to display

I am developing an iOS application in Swift.

I display data from database inside a collectionview but it takes too much time to appear on screen.
Surely a thread problem because on Xcode console, I can see data being displayed 20 seconds before it appears on the screen. Here is my code :

How can I make the collectionView being displayed faster ?


If this happens, it means you are making UI changes from a thread other than the main thread. Try this:

func refresh() {
    dispatch_async(dispatch_get_main_queue(), {