Hello @icanzilb.
Thanks for the detailed tutorial on Realm. I have one question.
Whenever the app starts, the first time we use the main configuration the following will run once:
private static var copyInitialFile: Void = {
Exams.copyInitialData(
Bundle.main.url(forResource: "default_v1.0", withExtension: "realm")!,
to: RealmConfig.mainConfig.fileURL!)
}()
Is this needed in every app launch? Wouldn’t it suffice to happen once during the very first launch of the app (after its installation) and then never happen again, since we will have the initial data in the Documents folder?
Well if you just have a look at the copyInitialData you will see that it copies the file any time it doesn’t find the required realm file in the Library folder. So if the user deletes the file the app will copy the initial version next time the app starts.