Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(NSArray *)backupFilesListSorted:(NSString*)folderPath
  2. {
  3.    
  4.     NSFileManager *manager = [NSFileManager defaultManager];
  5.     NSArray *files = [manager contentsOfDirectoryAtURL:[NSURL URLWithString:folderPath]
  6.                             includingPropertiesForKeys:[NSArray arrayWithObject:NSURLContentModificationDateKey]
  7.                                                options:NSDirectoryEnumerationSkipsHiddenFiles
  8.                                                  error:nil];
  9.    
  10.     NSDictionary *dictionary = [[NSMutableDictionary alloc] init];
  11.     for(NSURL *urlfile in files) {
  12.         NSDate *date = nil;
  13.         if ([urlfile getResourceValue:&date forKey:NSURLContentModificationDateKey error:nil]) {
  14.             [dictionary setValue:urlfile forKey:[date description]];
  15.         }
  16.     }
  17.     NSLog(@"dic: %@", dictionary);
  18.    
  19.     NSArray *sortArray = [dictionary allValues];
  20.     NSLog(@"file: %@", sortArray);
  21.    
  22.     return sortArray;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement