Get file in local Directory

Swift 2.0

If you have been using the old way of Swift 1.2 to locate files in your local directory and documents folder, you can forget about that in Swift 2.0 in the latest Apple update of iOS 9.1 and Xcode 7.1.

Before you would use something like:

After I had to do some headbanging I finally got it to work, so here is the completed solution, in hoping that you don’t waste as much time as I did   :

 

So now I can get my file path with ‘fileInDocumentsDirectory(“somefilehere”) ‘

Keep in mind that I only use ‘.path’ because I already have other things using the path, so I am being lazy on changing these. However Apple is recommending that everyone starts using NSURLS instead.

Cheers !

2 thoughts on “Get file in local Directory

  1. Thank you. How do I load the content of the file? for example the text from a text document to a label.
    I had it working before Xcode 7 :-/