Значение типа «FileManager» не имеет члена «urlsForDirectory» — ошибка AppDelegate Swift 3

Поскольку я недавно обновился до XCode 8 Beta 5, я пытался решить эту ошибку в своем стеке основных данных appDelegate.

В этих строках кода я получаю следующую ошибку:

// MARK: - Core Data stack

lazy var applicationDocumentsDirectory: URL = {
    // The directory the application uses to store the Core Data store file. This code uses a directory named "fitness.paceapp.Pace" in the application's documents Application Support directory.
    let urls = FileManager.default.urlsForDirectory(.documentDirectory, inDomains: .userDomainMask)
    return urls[urls.count-1]
}()

lazy var managedObjectModel: NSManagedObjectModel = {
    // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
    let modelURL = Bundle.main.urlForResource("Dominos", withExtension: "momd")!
    return NSManagedObjectModel(contentsOf: modelURL)!
}()

введите здесь описание изображения

Любые идеи о том, что я мог пропустить. Я совершенно потерян, и там не так много ответов. Заранее спасибо.


person Gugulethu    schedule 11.08.2016    source источник
comment
Вы ознакомились с новым FileManagerсправочником по API?   -  person Hamish    schedule 11.08.2016


Ответы (1)


Ну вот,

lazy var applicationDocumentsDirectory: URL = {
        // The directory the application uses to store the Core Data store file. This code uses a directory named "fitness.paceapp.Pace" in the application's documents Application Support directory.
        let urls = FileManager.default.urls(for: FileManager.SearchPathDirectory.documentDirectory, in: FileManager.SearchPathDomainMask.userDomainMask)
        return urls[urls.count-1]
    }()

    lazy var managedObjectModel: NSManagedObjectModel = {
        // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
        let modelURL = Bundle.main.url(forResource: "Dominos", withExtension: "momd")!
        return NSManagedObjectModel(contentsOf: modelURL)!
    }()
person Community    schedule 11.08.2016