Reputation: 1748
I just got started with FileManager
and wanted to know if there was a way to query files against custom attributes without having to retrieve the contents of the files.
Similar to creationDate
or modificationDate
, I want to have an attribute called topicsCovered
which is an array of strings containing things such as "technology", "politics", etc. (for news articles). Since News Articles may have many images, I don't want to unnecessarily retrieve ALL the news articles, convert them into concrete types, and then filter out the ones I don't want (specially since I'll be storing a maximum of 500 articles, which would mean retrieving ~1gb worth of files from disk).
So if there is a way to query files before retrieving them using FileManager
please let me know since I feel retrieving ~1gb worth of files from disk may be a very expensive/heavy operation.
Thanks in advance!
Upvotes: 1
Views: 342
Reputation: 33967
You have a bunch of files in your system. I suggest that you create an extra file, "metadata", that contains the metadata about all the other files (for e.g. the topics covered information), and the URL/filenames to the files themselves. You could also store this metadata in CoreData or some database table.
Then when you are looking for all the "politics" articles for example, you open the metadata file and find all the entries that cover politics which will give you the filenames of the files you want to load.
Upvotes: 1