What's a quick way to test to see a file exists?

IosIphoneCocoa TouchNsfilemanagerFile Manager

Ios Problem Overview


I want to quickly check to see if a file exists in my iPhone app's Documents directory (or any path for that matter). I can enumerate through the directory's files, or I can try to open a specific file. What's the fastest way? I just need to know if the file is there or if it does not exist.

Ios Solutions


Solution 1 - Ios

Swift v3:

let fileExists = FileManager.default.fileExists(atPath: somePath)

Thanks to Nikolay Suvandzhiev.

Objective-C (Original):

BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:somePath];

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmahboudzView Question on Stackoverflow
Solution 1 - IosreinView Answer on Stackoverflow