如何在Swift 3中保持警告

时间:2016-11-04 15:54:51

标签: swift core-data swift3

我正在使用restKit +核心数据堆栈。它不是一个大问题,但它只会让我烦恼。这是我的代码中唯一的警告。 也许我对此做错了。请给我一些方法来沉默。

  

警告:不可变的值' persistentStore'从未使用过;考虑替换为' _'或删除它!

{
    let persistentStore: NSPersistentStore?
    do {
        try persistentStore = managedObjectStore?.addSQLitePersistentStore(atPath: storePath, fromSeedDatabaseAtPath: nil, withConfiguration: nil, options: nil)
    } catch {
        fatalError("Error migrating store")
    }
}

2 个答案:

答案 0 :(得分:0)

如果您不使用persistentStore,那么只需:

try _ = managedObjectStore?.addSQLitePersistentStore(atPath: storePath, fromSeedDatabaseAtPath: nil, withConfiguration: nil, options: nil)

答案 1 :(得分:0)

persistentStore 替换为 _ 。如果未使用返回值,则在swift 3中新添加此警告。