iPhone – Check the file extension in Objective-C

How to check the extension of files in the directory or search for some extensions, and different extensions, and any suggestions for doing this for iphone applications

Best wishes

You can use NSFileManager’s -contentsOfDirectoryAtPath: error: method to get the inclusion An array of directory contents (as strings). NSString has a -pathExtension method that makes it easy to get the file extension. All that’s left is to iterate through the array, looking for a string that matches the extension you are looking for. Or, You can use -filteredArrayUsingPredicate: to identify the matching string.

How to check the extension of the file in the directory or search for some extensions, and different extensions, and for the iphone application Any suggestions for doing this

Best wishes

You can use NSFileManager’s -contentsOfDirectoryAtPath:error: method to get An array containing the contents of the directory (as a string). NSString has a -pathExtension method that makes it easy to get the file extension. All that remains is to iterate the array, looking for a string that matches the extension you are looking for. Or , You can use -filteredArrayUsingPredicate: to identify the matched string.

Leave a Comment

Your email address will not be published.