ios - getting latest saved file from Directory -


I searched a lot but failed to find any solutions I am working on the app that is making the video and local The directory has been saved and is showing these saved videos on the front of the app. But I want to show only 6 latest saved videos on the screen. How do I get the latest video path from the directory? help please.

This is the code that I have used to get all the video files

  [[NSFileManager defaultManager] fileExistsAtPath: DocumentPath isDirectory: & amp; IsDir]; If (isDir) {NSMutableArray * contentItemArray = [[NSMutableArray alloc] init]; NSArray * contentOf directory = [[NSFileManager defaultManager] Contentoff DirectoryAct: Last Directory Error: NULL]; For (Int i = 0; I & lt; [contentOf Directory Number]; i ++) {NSString * fileName = [contentOfDirectory ObjectIntext: i]; If ([FileName.pathExtension is EqualToString: @ "mov"]) {[contentItemArray addObject: fileName]; }}}}    

You may find the date of creation and the last 6 Has been created, by doing this:

  [[NSFileManager default manager] filexstath: DocumentPath isDirectory: & amp; IsDir]; If (isDir) {NSMutableArray * contentItemArray = [[NSMutableArray alloc] init]; NSArray * contentOf directory = [[NSFileManager defaultManager] Contentoff DirectoryAct: Last Directory Error: NULL]; For (Int i = 0; I & lt; [contentOf Directory Number]; i ++) {NSString * fileName = [contentOfDirectory ObjectIntext: i]; If ([FileName.pathExtension is EqualToString: @ "mov"]) {[contentItemArray addObject: fileName]; NSURL * fileUrl = [NSURL URLWithString: DocumentPath]; NSDT * Filadet; [FileName getResourceValue: and file date for: NSURLContentModificationDateKey error: & amp; Error]; If (! Error) {// Here you will be able to read valid dates from phonetic variable}}}} *   

Hope this can help you, otherwise we will get something else.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -