Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Jack Farr
7,961 PointsCannot call value of non-function type 'FileManager'
I typed out the script and was told to change NSFileManager to FileManager. But once I changed it it told me it cannot call value of non-function type 'FileManager'
let urls = FileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
2 Answers

eberhapa
51,495 PointsChange it to let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)

Graham Connolly
25,475 PointsIf you are using the latest Xcode (Xcode 8), you can enable Swift 2.3 by going to build settings -> Swift Compiler Version -> Use Legacy Swift Language Version and set this to Yes instead of the default No.
Jonas Baschung
3,234 PointsJonas Baschung
3,234 PointsBecause you mentioned you had to change NSFileManager to FileManager I'm guessing you're using Swift 3. Apple made some serious changes to the language and the code of this course is not Swift 3 (or not yet, they will update). For your code, this should work:
lazy var applicationDocumentsDirectory: URL = { let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) return urls[(urls.endIndex - 1)] }()
Chances are high that you have to update every piece of code of this course to Swift 3 manually. You can do this in the meantime while taking the course, it won't be fun.
You can also download the project-files, open them with Xcode 8 (which I'm guessing you're working with) and let Xcode converting them for you to Swift 3.