0
我試圖讓一個TextView的插入點的MacOS試圖讓一個TextView的插入點的MacOS
// Get insertion point position
if let selectedRange = textView.selectedRange {
cursorPosition = textView.offset(from: textView.beginningOfDocument, to: selectedRange.start)
}
我得到這個錯誤:
Initializer for conditional binding must have Optional type, not 'NSRange' (aka '_NSRange')
我用類似的代碼在iOS和它的作品,我做錯了什麼?