0
다음 코드를 사용하여 NSTextView의 전경색을 얻으려고합니다. 불행히도 관련된 색상 공간과 관련된 런타임 오류가 발생합니다. 어떻게 해결할 수 나는 다음과 같은 런타임 오류 얻을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")
}
M :
[General] *** invalid number of components for colorspace in initWithColorSpace:components:count: