Dejan Zuza
Dejan Zuza

Reputation: 369

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")
    }
}

Upvotes: 0

Views: 215

Answers (2)

Satheshkumar
Satheshkumar

Reputation: 232

Replace persistentStore with _. This warning is newly added in swift 3 if returned value is not used.

Upvotes: 0

Rad'Val
Rad'Val

Reputation: 9231

If you don't use persistentStore, then simply:

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

Upvotes: 1

Related Questions