Unable to specify path when creating Realm instance

Asked 1 months ago, Updated 1 months ago, 4 views

let realm=try!Realm (path: path name you want to read)

It used to be possible as shown in , but after the Realm version reaches 1.0,

Argument labels' (path:) 'do not match any available overloads

The warning message now appears.

How do I resolve this warning?
Is there an alternative argument to path?

swift realm

2022-09-30 11:46

1 Answers

The path argument was recently changed to the parameter fileURL to match Swift's standard library.

https://realm.io/news/realm-objc-swift-0.99.0/

From now on, use Realm(fileURL:) or

try!Realm (fileURL:NSURL(fileURLWithPath: "/path/to/file")))

Configure the file path using Realm.Configuration.

try!Realm(configuration:Realm.Configuration(fileURL:NSURL(fileURLWithPath:"/path/to/file"))))


2022-09-30 11:46

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.