简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM