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