I have a UILabel
that contains text like this:
"Hi, my name is John Smith. Here is my twitter handle @johnsmith and I work for this company @somerandomcompany. Thanks for watching!"
I need to find the ranges for all of the @
symbols and whatever text comes right after them until a space appears, so that I can then bold both the symbol and any text that comes after it until a space appears:
"Hi, my name is John Smith. Here is my twitter handle @johnsmith and I work for this company @somerandomcompany. Thanks for watching!"
I am familiar with using rangeOfString
but I have never had to handle multiple ranges like this. I need these NSRanges
so that I can pass them into a UILabel
category that will bold the appropriate text.
Any help is greatly appreciated.