Hello! I’ve only been learning swift for a few weeks, so I apologize if this is a silly or basic question - I tried to think of ways to word it when googling for an answer, but couldn’t find anything.
I’m trying to write code that lets you write a note, then highlight or select part(s) of that note and tag them as belonging to a specific category or list. Then when you flip to a view for that tag, you just see the selected parts of the notes that were tagged as being that category. It’s important that if you later change the note, that you can see the changes in the category view, too. So basically I want to be able to “tag” just part of the text of a note.
I’d like advice on either how to go about setting up data/instances like this, or what I should learn about or google keywords to figure out how to do this.
I did think about how to do this and came up with a few options, but am not sure how to translate it into swift code:
- Somehow create a pointer that points to the selected section of a note text (no clue if this is possible)
- Create a duplicate of the section that is selected, but somehow make a strong link between that and the section in the original note, so that if the note is changed, the change will be reflected everywhere in the app.
- Somehow hide in the text of the note a signifier that that chunk is special and is tagged. This is hard to articulate but I’m thinking like how () in swift tells swift “what’s inside this isn’t a string, it’s something else.”
- Instead of having the base unit be a note, have it be a "block", so each time you enter you’re making a new object. Then set up tags for the blocks. You'll only be able to highlight whole passages separated by an enter, but maybe that is better/easier to work with.
I'm still getting comfortable with when to use a class vs struct, so any advice on that in this context would be welcome, too.
Thank you for your time. If this is too confusing of a question, I will try to learn more and then break the post down into smaller questions.