Код: Выделить всё
// The label created with `attributedText`.
let label = UILabel()
label.attributedText = self.init(html: "[list][*]1th item[*]2th item[*]3rd item[/list]")
// The convenience function to init html `NSAttributedString` with a string instead of data.
extension NSAttributedString {
public convenience init(html: String) {
guard let encodedData = html.data(using: String.Encoding.utf16) else {
print("Unable to encode html string to data")
self.init(string: html)
return
}
assert(Thread.isMainThread, "The HTML importer should not be called from a background thread!")
do {
try self.init(
data: encodedData,
options: [
.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf16.rawValue,
],
documentAttributes: nil
)
} catch {
print("Initialising NSAttributedString with html failed \(error)")
self.init()
}
}
}
Я ожидал, что номера элементов списка (ожидаемый результат) отображаются при использовании `NSAttributedString` на основе `html`. Но с Xcode 16 это не работает. Он не показывает пункты списка. (фактический результат)
Подробнее здесь: https://stackoverflow.com/questions/790 ... ncorrectly