In AppDelegate file I create a Realm instance and pass it to another ViewController as follows:
var config = Realm.Configuration() config.readOnly = true config.fileURL = URL(fileURLWithPath: Bundle.main.path(forResource: "Questions", ofType: "realm")!) domainViewController.realm = try! Realm(configuration: config)
Now, in domainViewController I get array of objects, let’s say questions based on a specific user selection. This array is used to extract distinct values of a certain column which are displayed in yet another ViewController, called listViewController. Now, listViewController doesn’t need questions array yet but the ViewController that goes after listViewController needs it.
Is it better to pass Realm instance of database and then retrieve objects again or pass objects array (as it is already retrieved from the database) to another ViewController? Which is more efficient way of doing it?