12

セミコロンで区切られた文字列がいくつかあるNSTextViewがあります。私はそれらの弦のどれにカレットが置かれているかを見つける必要があります。どうすればそれができますか?

4

2 に答える 2

29
NSInteger insertionPoint = [[[myTextView selectedRanges] objectAtIndex:0] rangeValue].location;
于 2009-11-09T15:18:44.407 に答える
3

Swift4の場合

let insertionPointIndex = myTextView.selectedRanges.first?.rangeValue.location
于 2018-12-04T15:56:26.023 に答える