NSMakeRangeFromString
parses a textual representation of a range, it doesn’t create a range which covers a string. As your text contains no integers it returns the range {0, 0}
- location and length both zero. So therefore your text is not styled.
Replace with NSMakeRange(0, str.length)
and your code should work.