Reputation: 47348
Is there some way on iOS to add attributes to a file that I'm saving in the documents directory? Ideally I would have the file name, created date and duration.
I'm currently using two date formatters formatters and am using the filename to store date. This will quickly prove unmanageable if I need to store extra arguments.
//to save file
[_dateFormatter setDateFormat:@"MMddyyyyHHmmss"];
//to display file date to the user
[_displayDateFormatter setDateFormat:@"EEEE MMMM d, YYYY HH:mm"];
Is there a way to add metadata to file with the name and date?
Upvotes: 1
Views: 1167
Reputation: 1629
Extended file attributes can be used for application-specific data. To set an attribute, you'd use the setxattr function. Attributes are stored as name:data pairs and associated with the filesystem object. This NSHipster post discusses the use of extended attributes.
Another approach, if you don't need the file itself to encapsulate all relevant information, is to maintain a database with metadata for each file.
Upvotes: 4