On Aug 22, 2008, at 2:27 AM, Phil wrote:
On Fri, Aug 22, 2008 at 6:29 PM, Adil Saleem <[EMAIL PROTECTED]> wrote:Currently what i am doing is that i am getting the file names in an NSMutableArray using NSFileManager function directoryContentsAtPathI get the list, but the problem is that it get all the files. I want only those files that have a certain extension (for example mp4, mp3). How can i do that.I'd recommend using -enumeratorAtPath: and adding each path that meets your criteria to a new array. Also, consider if you want to check for a particular file extension, or a particular file type: do you just want files ending in ".mp3", or any valid MP3 file? If you want the latter, then you should investigate checking the file extensions for conformance against the particular UTIs you're interested in. The documentation for UTIs isn't great, but take a look at the UTType.h and UTCoreTypes.h header files.
I agree that Using UTIs is a good idea in general. If you can use extensions, though, you can filter out all filenames with a single call to -[NSArray pathsMatchingExtensions:].
-- Adam
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]