2016-11-04 41 views
0

我正在使用restKit +核心数据堆栈。这不是一个大问题,但它只是让我感到困扰。这是我的代码中唯一的警告。 也许我正在做这个错误。只要给我一些方法来保持沉默。如何在Swift中静默警告3

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

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

回答

0

如果你不使用persistentStore,后来干脆:

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

+0

Tx,我在后来想到它,它的速度很快。这发生在代码转换之后。 –

0

更换persistentStore_。如果未使用返回值,则会在swift 3中新添加此警告。