J'essaie d'utiliser le code suivant pour obtenir la couleur de premier plan d'un NSTextView. Malheureusement, je reçois une erreur d'exécution qui doit être liée aux espaces colorimétriques concernés. Comment puis-je résoudre suisImpossible d'obtenir la couleur de premier plan de NSTextView
if let textStorage = textView.textStorage {
let rowObj = textStorage.paragraphs[row]
let range = NSMakeRange(0, rowObj.string.characters.count)
colorOrRowBeforeSelection = rowObj.foregroundColor!
if(rowObj.foregroundColor != nil) {
let r = rowObj.foregroundColor!.redComponent
let g = rowObj.foregroundColor!.greenComponent
let b = rowObj.foregroundColor!.blueComponent
} else {
Log.e("cannot get foreground color components")
}
} else {
Log.e("textStorage = nil")
}
Je reçois l'erreur d'exécution suivante:
[General] *** invalid number of components for colorspace in initWithColorSpace:components:count: