Hi All,
Any help regarding the preloaded realm file using the latest version of xcode and swift, I have to include a preloaded realm file in my project.
Any suggestion or sample link?
Thanks.
@rjjohnpatrickcruz There are some explanations for preloaded realm file in our documentation: Other Realms and Bundling a Realm with an App I hope these help.
It's quite easy to bundle preloaded Realm files in your app.
let config = Realm.Configuration(
// Get the path to the bundled file
path: NSBundle.mainBundle().pathForResource("MyBundledData", ofType:"realm"),
// Open the file in read-only mode as application bundles are not writeable
readOnly: true)
// Open the Realm with the configuration
let realm = try! Realm(configuration: config)
// Read some data from the bundled Realm
let results = realm.objects(Dog).filter("age > 5")
Thanks! @kishikawakatsumi I try this.
its working @kishikawakatsumi! Thanks. cheers!
@rjjohnpatrickcruz My pleasure!
@kishikawakatsumi Thanks for the example. By the way, the Realm docs needs updating. Realm.Configuration doesn't seem to have that particular initializer anymore.
Which docs? We use fileURL in all our docs as far as I know.
Most helpful comment
@rjjohnpatrickcruz There are some explanations for preloaded realm file in our documentation: Other Realms and Bundling a Realm with an App I hope these help.
It's quite easy to bundle preloaded Realm files in your app.