Unable to specify path when creating Realm instance

Asked 2 years ago, Updated 2 years ago, 51 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


© 2024 OneMinuteCode. All rights reserved.