IOS sort files in folder by date added

My app downloads files from the internet. The application stores them in the Documents folder. The app uses the iTunes sharing feature and the user can store files in the Documents folder via iTunes (when my app is running and when my app is not running). In one of the table views in my application, I want to present files from the Documents directory, sorted by the date they were added (the date the files were added to the Documents directory). Is there any file attribute like "Date Added" on iOS? How can I get it? I have searched for this but at the moment I cannot find an answer.

I think I can keep the date for uploaded files and files that were added via iTunes when my application was launched using DirectoryWatcher. But I don't know how I can get the "added date" for files that were saved in documents via iTunes when my application was not running. How can i do this?

I know there is Arrange by Date Added in Finder on Mac OS 10.7. How do they do it?

Thank.

+3


source to share


2 answers


I found that the file does not contain Date Added in its attributes. After copying files via iTunes Connect from Mac, the application creation date and modification date remain the same (just like on Mac). Also I found that Finder on Mac uses an external sqlite database ~ / Library / Preferences / com.apple.dock.db to store the Date Added attribute.



So, for my needs I decided to use some kind of external database to store the "date added" value. I think I will use NSUserDefaults and I will use the filename and inode number as the key.

0


source


Yes, you can use NSFileManager for this, you can give it the file path to query the attribute dictionary which is the modified date



https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDictionary/fileModificationDate

+2


source







All Articles