How do I turn off the SQLite Write ahead logging (WAL) in Core Data using Apples new programming language Swift?
In ObjC I used to pass in the key value pair @"journal_mode": @"DELETE" in the options dictionary:
[storeCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:[self databaseURL]
options:@{NSMigratePersistentStoresAutomaticallyOption: @YES,
NSInferMappingModelAutomaticallyOption: @YES,
@"journal_mode": @"DELETE"}
error:&error]
But in Swift only the same types are allowed in a NSDictionary, so mixing BOOL (that is mapped to NSNumber) and NSString is not possible.
Any ideas?
These answers were close but neither were actually working for me. The following does work. The option must be as as a NSSQLitePragmasOption
.
var options = Dictionary<NSObject, AnyObject>()
options[NSMigratePersistentStoresAutomaticallyOption] = true
options[NSInferMappingModelAutomaticallyOption] = true
options[NSSQLitePragmasOption] = ["journal_mode" : "DELETE"]
if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: options, error: &error) == nil {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With