Instance member ‘URLsForDirectory’ cannot be used on type ‘FileManager’

How do I get rid of the error in the Post name above which is located on the guard statement below?

 

func initializeCoreDataStack() {

        guard let modelURL = Bundle.main.url(forResource: “Asset”, withExtension: “momd”) else {

            fatalError(“Failed to Model.momd in app bundle”) }

      

        guard let mom = NSManagedObjectModel(contentsOf: modelURL) else  {

            fatalError(“Failed to initialize MOM”) }

 

        let psc = NSPersistentStoreCoordinator(managedObjectModel: mom)

        let queue = DispatchQueue.global(qos: .background)

        queue.async {

        }

        queue.async() {

            let fileManager = FileManager.default

            guard let documentsURL = FileManager.URLsForDirectory(.applicationSupportDirectory, inDomain: .userDomainMask).last else {

                fatalError(“Failed to resolve documents directory”)    ********************************  Error occurs here ************************************

            }

            let storeURL = documentsURL.URLByAppendingPathComponent(“Asset.sqlLite”)

            do {

                try psc.addPersistentStoreWithType(NSSQLiteStoreType,

                configuration: nil, URL: storeURL, options: nil)

            } catch {

                fatalError(“Failed to initialize PSC: (error)”)

            }

            }

        }

    }

Powered by WPeMatico

You may also like...

Comments are closed.