check for file extension in objective-c
how to check the extensions of files in direc开发者_如何学Ctory or search for certain extension amog different extensions , any suggestion to do that for iphone applications
Best regards
You can use NSFileManager's
-contentsOfDirectoryAtPath:error:
method to get an array with the contents of a directory (as strings). NSString
has a -pathExtension
method that makes it easy to get the file extension. All that remains is to iterate over the array looking for strings whose -pathExtension
matches the extension you're looking for. Alternately, you could probably use -filteredArrayUsingPredicate:
to identify the matching strings.
精彩评论