Dejan Zuza Dejan Zuza - 1 month ago 37
Swift Question

How to silence warning in Swift 3

I am using restKit + core data stack. It's not like it's a big problem, but it just bugs me. This is the only warning in my code.
Maybe I am doing something wrong with this. Just give me some way to silence this.


Warning: Immutable value 'persistentStore' was never used; consider replacing with '_' or removing it!


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

Answer

If you don't use persistentStore, then simply:

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