NSRange da Swift Range?
Problema: NSAttributedString pega um NSRange enquanto estou usando uma Swift String que usa Range
let text = "Long paragraph saying something goes here!"
let textRange = text.startIndex..<text.endIndex
let attributedString = NSMutableAttributedString(string: text)
text.enumerateSubstringsInRange(textRange, options: NSStringEnumerationOptions.ByWords, { (substring, substringRange, enclosingRange, stop) -> () in
if (substring == "saying") {
attributedString.addAttribute(NSForegroundColorAttributeName, value: NSColor.redColor(), range: substringRange)
}
})
Produz o seguinte erro:
erro: 'Range' não é convertível em 'NSRange' attributeString.addAttribute (NSForegroundColorAttributeName, valor: NSColor.redColor (), range: substringRange)