I figured out a clumsy way to convert NSTextRange to NSRange, of cause by researching the development documents for ages.
let offset = textContentStorage!.offset(from: textLayoutManager!.documentRange.location, to: textRange.location)
let length = textContentStorage!.offset(from: textRange.location, to: textRange.endLocation)
let nsRange = NSRange(location: offset, length: length)
Topic:
App & System Services
SubTopic:
General
Tags: