Я нашел решение.
fun c getAttributedText (_ text1: String, text2: String) -> NSAttributedString {
let attribute.String1 = NSMutableAttributedString (строка: "(text1) \ n", атрибуты: ноль)
let attribute.String2 = NSMutableAttributedString (строка: "(text2) \ n", атрибуты: ноль)
attribute.String1. 1012 * let originalString = "https://medium.com/@felicity.johnson.mail / how-to-split-a-string-swift-3-0-e9b757445064 проверка нового сообщения"
do {
let types: NSTextCheckingResult.CheckingType = .link
let detector = try? NSDataDetector(types: types.rawValue)
let matches = detector?.matches(in: originalString, options: .reportCompletion, range: NSMakeRange(0, originalString.count))
var link:String!
if (matches != nil){
for match in matches! {
link = (match.url?.absoluteString)!
break;
}
}
let mutableAttributedString = NSMutableAttributedString(string: originalString, attributes: nil)
let attributedText = getAttributedText("DOJ watchdog finds no bias in launch of Trump-Russia probe, but uncovers ‘significant’ FBI errors", text2:"The Justice Department’s inspector general, in a long-awaited review concerning the origins of the Russia investigation \n")
let userContent : String = ""
// Get range of text to replace
if let range = mutableAttributedString.string.range(of: link){
let nsRange = NSRange(range, in: mutableAttributedString.string)
// Replace content in range with the new content
mutableAttributedString.replaceCharacters(in: nsRange, with: userContent)
}
let userTypedContent = mutableAttributedString.string.trimmingCharacters(in: .whitespaces)
let urlContent = attributedText.string.trimmingCharacters(in: .whitespaces)
UIlablel.text = urlContent + userTypedContent }