swift - 警告 : Expression following 'return' is treated as an argument of the 'return'

标签 swift warnings compiler-warnings

我在我的代码中收到此警告,但我无法弄清楚它的含义以及我需要做些什么来修复它。
警告说如下:

Expression following 'return' is treated as an argument of the 'return'



它显示在这一行:
// Tell Realm to use this new configuration object for the default Realm

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

一些背景信息,代码是我用来将未加密的领域数据库迁移到加密的数据库管理器类的一部分,如果加密的数据库尚不存在。
如果加密的 db 已经存在,它会将领域配置为默认使用这个。如果它无法打开它(例如,由于错误的加密 key ),它会创建一个新数据库。
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
简单的方式享受它

//MARK:- Use it like function its will work
return()

关于swift - 警告 : Expression following 'return' is treated as an argument of the 'return' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36769572/

相关文章:

swift - 如何删除 SnapShot 监听器(Firestore - Swift)

iOS - 多通知扩展服务?

swift - 从 Sprites UserData 中保存和读取信息

python - 为什么 PyCharm 会警告可变的默认参数?我该如何解决它们?

c - 为什么 "implicit declaration of function"只是一个警告?

cocoapods - 运行 pod install 时出现 "Your project does not explicitly specify the CocoaPods master specs repo"警告

c - 在函数结构上静默 WCast-function-type

c - 是否可以在编译时检测 C 中的范围错误

ios - 当Int溢出导致IOS app crash时,如何remark

c++ - Xcode 为 c++ 中的显式死代码提供了奇怪的解决方案?