警告:“ return”之后的表达式被视为“ return”的参数

Pau*_*aal 6 warnings compiler-warnings swift

我在代码中收到此警告,但无法弄清楚它的含义以及需要解决的问题。该警告内容如下:

“ return”之后的表达式被视为“ return”的参数

它显示在此行上:

// Tell Realm to use this new configuration object for the default Realm
Run Code Online (Sandbox Code Playgroud)

有人可以解释我在做什么错吗?参见下面的代码部分。

一些背景信息,该代码是数据库管理器类的一部分,如果加密的数据库尚不存在,我可以使用该类将未加密的领域数据库迁移到加密的领域数据库。如果已加密的数据库已经存在,则它将领域配置为使用该默认数据库。如果无法打开它(例如由于加密密钥错误),它将创建一个新数据库。

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)
}
Run Code Online (Sandbox Code Playgroud)

Sha*_*med 10

Swift 5 轻松享受它

//MARK:- Use it like function its will work
return()
Run Code Online (Sandbox Code Playgroud)