title: how to add specific attributes to a NSAttributedString in Swift
body: <p>This is a simple question but is erroring in several places so I think there's something I'm just not getting (and it's a coworkers app who's no longer here). I am migrating an Objective-C app to Swift and am having some problems with NSAttributedString. </p>
  
  <p>There is a note.body which gets set to an NSMutableAttributedString and each note has a .frags array of strings which are the sections that we want to add the attributes to.</p>
  
  <p>I have:</p>
  
  <pre><code>var attrs = [NSFontAttributeName : UIFont.systemFontOfSize(9.0)]
  var gString = NSMutableAttributedString(string:note.body, attributes:attrs)  // say note.body="birds and bees"
  
  let firstAttributes = [NSForegroundColorAttributeName: UIColor.blueColor(), NSBackgroundColorAttributeName: UIColor.yellowColor(), NSUnderlineStyleAttributeName: 1]
  for (val) in note.frags {  // say note.frags=["bees"]
    let tmpVal = val
    gString.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.StyleDouble.rawValue, range: gString.string.rangeOfString(tmpVal))
  }
  </code></pre>
  
  <p>How would I add the first attributes?</p>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>Cannot invoke 'addAttribute' with an argument list of type '(String,
    value: Int, range: Range?)'</p>
  </blockquote>