[英]What's a quick way to test to see a file exists?
I want to quickly check to see if a file exists in my iPhone app's Documents directory (or any path for that matter). 我想快速检查我的iPhone应用程序的Documents目录(或任何路径)中是否存在文件。 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.
我只需要知道文件是否存在或者是否存在。
Swift v3: Swift v3:
let fileExists = FileManager.default.fileExists(atPath: somePath)
Thanks to Nikolay Suvandzhiev . 感谢Nikolay Suvandzhiev 。
Objective-C (Original): Objective-C(原创):
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:somePath];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.