So I'm still using Swift3 but getting compiler warnings of a snippet I'm using from NSRange and Swift, I do not understand, specifically this function:
/// Returns a substring with the given `NSRange`,
/// or `nil` if the range can't be converted.
func substring(with nsrange: NSRange) -> String? {
guard let range = nsrange.toRange()
else { return nil }
let start = UTF16Index(range.lowerBound)
let end = UTF16Index(range.upperBound)
return String(utf16[start..<end])
}
which Xcode 9 complains re: the range fetches that 'init' is deprecated. I think the type alias - UTF16Index, usage is the issue but short of ripping this all out I'd like to try to understand and a resolution.