Re: File Extensions Problem
Re: File Extensions Problem
- Subject: Re: File Extensions Problem
- From: "Adam R. Maxwell" <email@hidden>
- Date: Fri, 22 Aug 2008 07:48:42 -0700
On Aug 22, 2008, at 2:27 AM, Phil wrote:
On Fri, Aug 22, 2008 at 6:29 PM, Adil Saleem
<email@hidden> wrote:
Currently what i am doing is that i am getting the file names in an
NSMutableArray using NSFileManager function directoryContentsAtPath
I 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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden