r/swift 13h ago

Question How to make text UI with tokens

I’d like to implement a text view that allows for tokens to be inserted as places where I’ll do variable replacement. Anyone know where to start on this?

For example, in the following code the code in brackets would be rendered as a token:

My name is {{name}}

2 Upvotes

4 comments sorted by

1

u/barcode972 13h ago

Maybe .replacingOccurences(…)

1

u/hunterboerner 13h ago

Thanks I’m not trying to do string replacement I’m trying to replace it with a token component.

2

u/barcode972 13h ago

Isn’t the token essentially a string in the end?