N
N
NONAME82018-05-29 15:52:47
iOS
NONAME8, 2018-05-29 15:52:47

I don't know how to correctly pass a dictionary to a function argument?

I'm converting code from Objective-C to Swift.
5b0d4bc4cbc02148250903.png
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

1 answer(s)
D
doublench21, 2018-05-29
@NONAME8

So what's the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question