[英]check for file extension in objective-c
how to check the extensions of files in directory or search for certain extension amog different extensions , any suggestion to do that for iphone applications 如何检查目录中文件的扩展名或搜索某些扩展名,以及不同的扩展名,以及为iphone应用程序执行此操作的任何建议
Best regards 最好的祝福
You can use NSFileManager's
-contentsOfDirectoryAtPath:error:
method to get an array with the contents of a directory (as strings). 您可以使用
NSFileManager's
-contentsOfDirectoryAtPath:error:
方法获取包含目录内容(作为字符串)的数组。 NSString
has a -pathExtension
method that makes it easy to get the file extension. NSString
有一个-pathExtension
方法,可以很容易地获得文件扩展名。 All that remains is to iterate over the array looking for strings whose -pathExtension
matches the extension you're looking for. 剩下的就是迭代数组,寻找
-pathExtension
与你正在寻找的扩展相匹配的字符串。 Alternately, you could probably use -filteredArrayUsingPredicate:
to identify the matching strings. 或者,您可以使用
-filteredArrayUsingPredicate:
来标识匹配的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.