Re: File Extensions Problem
Re: File Extensions Problem
- Subject: Re: File Extensions Problem
- From: Michael Dautermann <email@hidden>
- Date: Fri, 22 Aug 2008 03:10:05 -0400
On Aug 22, 2008, at 2:29 AM, Adil Saleem wrote:
Hi,
I want to display in a tableview, list of all media files (audio,
video files) present in a certain directory.
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.
Thanx in advance
After fetching the contents and before displaying contents in the
table view, why not enumerate through the mutable array and remove any
files that *do not have* the extensions you are looking for.
You can do something like:
NSString * fullFileName;
en = [ myMutableArray objectEnumerator ]
while(( fullFileName = [ en nextObject ) != NULL )
{
// if the file is not an .mp3 file...
if( [[ fullFileName pathExtension ] compare: @".mp3" options:
NSCaseInsensitiveSearch ] != NSOrderedSame )
[ myMutableArray removeObject: fullFileName ]; // .. remove it
}
In other words, [ NSString pathExtension ] could be very helpful to
you here.
_______________________________________________
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