cedric petetin cedric petetin - 2 years ago 107
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 ?

Answer Source

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(), {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download