开发者

check for file extension in objective-c

开发者 https://www.devze.com 2023-02-15 09:17 出处:网络
how to check the extensions of files in direc开发者_如何学Ctoryor search for certain extension amog different extensions , any suggestion to do that for iphone applications

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消