开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜