In a super simple form (i.e. there are many ways you can build on this to make it scalable):
- If each note is text, create an object with properties for the text and the tags
- Make the tags property an array of strings
- Store the notes in an array initially (archive to save to disk, or just practice with a non-saved version)
- Make the user enter the tags (auto-tagging is an interesting topic...)
- Consider using a
token field
(google for 3rd party implementations) for tag entry
Now, when a user starts a search for tagged content, iterate through each of the notes you have and run a predicate on the tag array. This could be done using NSPredicate
, or you could ensure that all tags are saved in lower case and, to start with, require exact matching - so you could use '[tagArray containsObject:userEnteredTag];`
Then:
- Look at real predicates
- Look at Core Data (or SQLite if you love it)