I have a question about Realm.
I am currently developing an application using SwiftUI, but what should I do if I use the Realm file created by Realm Studio within the application?
let realm=try!Realm()
let config = Realm.Configuration(fileURL:URL("filetopath")!, readOnly:true)
Realm.Configuration.defaultConfiguration=config
I've been here, but
let data=realm.objects (Hoge.self)
print(data)
It does not show the contents.
I have hardly touched Realm, and I am a beginner at Swift, so I would appreciate it if you could tell me.
swift realm swiftui
Self-resolved.
I put the Realm file in the project folder and I was able to code it as follows.
let realm=try!Realm (fileURL: URL (string: Bundle.main.path (forResource: "default", ofType: "realm")!)
© 2024 OneMinuteCode. All rights reserved.