Check file extension in objective-c

how to check file extensions in a directory or look for specific amog extensions of different extensions, any suggestion to do this for iphone applications

Regards

+3
source share
1 answer

You can use the method NSFileManager's -contentsOfDirectoryAtPath:error:to get an array with the contents of the directory (as strings). NSStringhas a method -pathExtensionthat makes it easy to get the file extension. All that remains is to iterate over the array looking for strings whose -pathExtensionextension matches what you are looking for. Alternatively, you could use -filteredArrayUsingPredicate:to determine the corresponding strings.

+7
source

All Articles