Arkelyan
Arkelyan

Reputation: 250

Swift 3 NSFileManager Xcode 8 Error: Has been renamed FileManager

Trying to get default documents directory in Swift 3 but says it has been renamed to FileManager. If update to FileManager then get error: Cannot call value of non-function type FileManager

Xcode 8. Swift 3 Beta 4.

using this line of code from FMDB Swift Instructions:

let documents = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)

Upvotes: 4

Views: 6896

Answers (1)

Leo Dabus
Leo Dabus

Reputation: 236370

URLForDirectory has been renamed to url(for: in: appropriateFor: create: ). You have to do as follow:

let documents = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)

Upvotes: 6

Related Questions