[swift-dev] [SourceKit] NSRange, Swift.String, and NSString

Tyler Stromberg tylers at mac.com
Fri Mar 24 12:59:01 CDT 2017


I'm currently working on integrating SourceKit with a macOS application. AppKit APIs (e.g. NSAttributedString, NSLayoutManager, etc) deal in terms of NSRange (UTF-16 code units?). SourceKit, however, deals in terms of integer offsets and lengths (UTF-8 code units?). Is there a more efficient or easier way to convert back and forth between the two other than doing the index(_:offsetBy:) -> samePosition(in:) dance?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20170324/ccfc6e55/attachment.html>


More information about the swift-dev mailing list