Sorry, dumb question number 2 today. Is it possible to determine if a file is contained within the App Bundle? I can access files no problem, i.e.,
NSString *p
Same as @Arkady, but with Swift 2.0:
First, call a method on mainBundle()
to help create a path to the resource:
guard let path = NSBundle.mainBundle().pathForResource("MyFile", ofType: "txt") else {
NSLog("The path could not be created.")
return
}
Then, call a method on defaultManager()
to check whether the file exists:
if NSFileManager.defaultManager().fileExistsAtPath(path) {
NSLog("The file exists!")
} else {
NSLog("Better luck next time...")
}