NSRange de Swift Range?
Problema: NSAttributedString toma un NSRange mientras uso una cadena Swift 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)
}
})
Produce el siguiente error:
error: 'Rango' no es convertible a 'NSRange' atribuidoString.addAttribute (NSForegroundColorAttributeName, valor: NSColor.redColor (), rango: substringRange)