I get this warning in my code and I can't figure out what it means and what I need to do to fix it. The warning says the following:
Expression following 'return' is treated as an argument of the 'return'
And it's shown on this line:
// Tell Realm to use this new configuration object for the default Realm
Can someone explain what I'm doing wrong? See code part below.
Some background info, the code is part of a database manager class which I use to migrate a unencrypted realm database to an encrypted one, if the encrypted db doesn't exist yet. If the encrypted db already exists, it configures realm to use this one as default. If it cannot open it (e.g. because of wrong encryption key) it creates a new database.
let exists = self.encryptedDatabaseExists(config)
if exists {
//Try to open Realm with new config. If unsuccessful, it needs to be removed and a new one created
do {
_ = try RLMRealm(configuration: config)
// Tell Realm to use this new configuration object for the default Realm
RLMRealmConfiguration.setDefaultConfiguration(config)
RLMRealm.defaultRealm()
} catch let err {
Log.error("Encrypted DB could not be opened: \(err)")
self.createNewEncryptedDatabase(config)
}
} else {
self.migrateToEncryptedDatabase(config)
}
Swift 5 Easy way enjoy it
//MARK:- Use it like function its will work
return()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With