Get directory contents in date modified order

Posted by nevan on Stack Overflow See other posts from Stack Overflow or by nevan
Published on 2009-10-06T05:47:19Z Indexed on 2010/03/29 5:23 UTC
Read the original article Hit count: 433

Filed under:
|
|

Is there an method to get the contents of a folder in a particular order? I'd like an array of file attribute dictionaries (or just file names) ordered by date modified.

Right now, I'm doing it this way:

  • get an array with the file names
  • get the attributes of each file
  • store the file's path and modified date in a dictionary with the date as a key

Next I have to output the dictionary in date order, but I wondered if there's an easier way? If not, is there a code snippet somewhere which will do this for me?

Thanks.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about nsfilemanager