I've searched a lot but fail to find any solution. I'm working on app that create video and saved at local directory and showing these saved video on front screen of the app. But I want to show only 6 latest saved videos on screen. How can I get the latest videos path from directory . Please help.
This is code which I've used to get all video files
[[NSFileManager defaultManager] fileExistsAtPath:DocumentPath
isDirectory:&isDir];
if ( isDir ) {
NSMutableArray *contentItemArray = [[NSMutableArray alloc] init];
NSArray *contentOfDirectory =
[[NSFileManager defaultManager] contentsOfDirectoryAtPath:finalDirectory
error:NULL];
for (int i = 0; i<[contentOfDirectory count]; i++) {
NSString *fileName = [contentOfDirectory objectAtIndex:i];
if([fileName.pathExtension isEqualToString:@"mov"])
{
[contentItemArray addObject:fileName];
}
} }