2016-08-11 17 views
1

私は最近XCode 8 Beta 5に更新して以来、私はappDelegate Core Data Stackでこのエラーを解決しようとしています。これらのコード行でタイプ 'FileManager'の値に 'urlsForDirectory'のメンバーがありません - AppDelegate Swift 3エラー

私は次のエラーを取得する:

// 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)! 
}() 

enter image description here

私が行方不明何ができるか上の任意のアイデアを。私はかなり失われており、そこには多くの答えがありません。前もって感謝します。

+1

は、新しい[ 'FileManager' APIリファレンス](HTTPSを見たことがあり//developer.apple.com/reference/foundation/nsfilemanager)? – Hamish

+0

[FileManagerとurlsForDirectoryの重複した可能性があるSwift 3 Xcode Beta 4のエラー](http://stackoverflow.com/questions/38754426/filemanager-and-urlsfordirectory-error-in-swift-3-xcode-beta-4) –

答えて

4

あなたが行く、

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)! 
    }() 
+0

どうもありがとう。 ;) – Gugulethu

0

それは次のとおりです:

let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) 
return urls.last! 

それとも

ここ
return try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) 
関連する問題