Same as @Arkady, but with Swift 2.0:
First call the mainBundle() method to create the path to the resource:
guard let path = NSBundle.mainBundle().pathForResource("MyFile", ofType: "txt") else { NSLog("The path could not be created.") return }
Then call the method on defaultManager() to check if the file exists:
if NSFileManager.defaultManager().fileExistsAtPath(path) { NSLog("The file exists!") } else { NSLog("Better luck next time...") }
sudo make install Jul 25 '15 at 10:52 2015-07-25 10:52
source share