Guest User

Untitled

a guest
Jul 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. //Create dictionary with attributes I care about and a fileList array
  2.  
  3. NSMutableArray *fileList = [[NSMutableArray alloc] initWithCapacity:10];
  4. NSDictionary *fileData = [NSDictionary dictionaryWithObjectsAndKeys:file, @"file", dateString, @"date", nil];
  5.  
  6. [fileList addObject:fileData];
  7.  
  8. //I don't know how to sort this array by the "date" key!
  9.  
  10. NSArray *files = [fm contentsOfDirectoryAtPath:folderPath error:NULL];
  11. //iterate through files array
  12. for (NSString *file in files) {
  13. NSString *path = [folderPath stringByAppendingPathComponent:file];
  14. //code to create custom object with contents of file as properties
  15. //feed object to fileList, which displays it in the tableview
  16.  
  17. NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
  18. [sortedFiles sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];
  19.  
  20. NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
  21. [sortedFiles sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];
Add Comment
Please, Sign In to add comment