I've been reading a bunch of Stack Overflow posts and the documentation, but I can't seem to achieve the results I'm after. :grimacing:
I am building a game where most of the in-game content, add-ons, etc are being stored in Realm. I would like to pre-populate a Realm (that's being stored in the app's bundle) with this data and copy all of it to the default Realm when the app is launched for the first time.
unlocked value that will determine if the user can see that bit of content.Copy all data to the default Realm on first launch.
Nothing right now, Not sure where to start.
Realm v0.98.5
I'd appreciate a push in the right direction. :dancer:
Have you read the Bundling a Realm with an App section of our docs? I recommend you start there, and if you run into problems, let us know what went wrong.
Thanks @jpsim! I'll take a look and see how far I get. :+1:
The Bundling a Realm with an App guide got me pretty far in achieving what I wanted, but I'm having issues figuring out how to create a fresh/empty *.realm file. Could you point me in the right direction?
let path = Realm.Configuration.defaultConfiguration.path!
// delete any previously created Realm files
do {
try NSFileManager.defaultManager().removeItemAtPath(path)
} catch {}
_ = try! Realm()
print("empty Realm created at path: \(path)")
Thanks again, @jpsim! :+1:
Most helpful comment