encodedOffset deprecation
yourString1.yourIndex.utf16Offset(in: yourString2)
A simple and correct way to create an NSRange
from a Range<String.Index>
is to use its initializer:
public init<R, S>(_ region: R, in target: S) where R : RangeExpression, S : StringProtocol, R.Bound == String.Index
In your case:
if let range = text.range(of: host) {
return NSRange(range, in: text)
}