title: How to change a text color for a certain attributed string or make it bold?
body: <p>Say I have NSString * hello = @"hello world";</p>
  
  <p>Now I want an atributed string where the hell in hello world is bolded.</p>
  
  <p>There is a function on the web that do this:</p>
  
  <pre><code>- (NSMutableAttributedString*) word:(NSString*)substringToHighlight{
  
      NSMutableAttributedString * mutableAttributedString = [[ NSMutableAttributedString alloc]initWithString:self];
      NSUInteger count = 0, length = [mutableAttributedString length];
      NSRange range = NSMakeRange(0, length);
  
      count = 0,
      length = [mutableAttributedString length];
      range = NSMakeRange(0, length);
      while(range.location != NSNotFound)
      {
          range = [[mutableAttributedString string] rangeOfString:substringToHighlight options:0 range:range];
          if(range.location != NSNotFound) {
  
              //[mutableAttributedString setTextColor:[UIColor blueColor] range:NSMakeRange(range.location, [word length])];
              range = NSMakeRange(range.location + range.length, length - (range.location + range.length));
              count++;
          }
      }
      return mutableAttributedString;
  }
  </code></pre>
  
  <p>However, the function doesn't work because mutableAttributedString doestn't support setTextColor</p>
  
  <p>I also tried</p>
  
  <pre><code>NSDictionary * dict = @{kCTFontAttributeName:boldFontName};
          [mutableAttributedString setAttributes:{kCTFontAttributeName:boldFontName} range:NSMakeRange(range.location, substringToHighlight.length)];
  </code></pre>
  
  <p>but got a message kCTFontAttributeName is not defined.</p>