Answer the question
In order to leave comments, you need to log in
I don't know how to correctly pass a dictionary to a function argument?
I'm converting code from Objective-C to Swift.
And I need to pass the options object as [AnyHashable:Any]?.
But I don't understand how it can be done.
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "App2")
let fileURL = applictationDocumentsDirectory().appendingPathComponent("App2.sqlite")
var options :[AnyHashable:Any]?
do{
// Сюда options и надо передать
try container.persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: fileURL, options: nil)
}
catch{
}
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question