Cannot convert value of type NSAttributedString.DocumentAttributeKey to .DocumentReadingOptionKey

前端 未结 8 1992
鱼传尺愫
鱼传尺愫 2020-12-09 07:18

I found this string extension somewhere on SO that allows me to turn html code into an attributed string:

func html2AttributedString() -> NSAttributedStri         


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 08:15

    Had this after automatic conversion to Swift 4. Was fixed by changing from:

    NSMutableAttributedString(data: data, 
       options: [NSAttributedString.DocumentAttributeKey.documentType : NSAttributedString.DocumentType.html], 
       documentAttributes: nil)
    

    to:

    NSMutableAttributedString(data: data,
       options: [.documentType : NSAttributedString.DocumentType.html],
       documentAttributes: nil) {
    

提交回复
热议问题