RealmSwift - what is the best way to load data to populate a complete NSOutlineView on macOS


#1

Hi, I am trying to figure out the best way to load a complex hierarchy into an outline view on macOS without blocking the UI thread. It takes 4 or 5 seconds to load because I have to load all the objects on the main thread so there is a noticeable impact to the while app UI.

Anyone have any suggestions on how to get around this? Normally I would try and load things on a background thread and once they are loaded then pass the data to the main thread.

It doesn’t seem like this is possible with Realm unless I load the realm objects on a background thread, store them in a separate non realm array of some sort and then pass them to the main thread. In the meantime show a single dummy record with a message saying ‘loading…’ or similar.

Any suggestions on the best way to do this with Realm would be appreciated.