ios - Swift-3 error: '-[_SwiftValue unsignedIntegerValue]: unrecognized selector -


following code worked old swift. extension of string

func stringbyconvertinghtml() -> string {     let newstring = replacingoccurrences(of: "\n", with: "<br>")     if let encodeddata = newstring.data(using: string.encoding.utf8) {         let attributedoptions : [string: anyobject] = [             nsdocumenttypedocumentattribute: nshtmltextdocumenttype anyobject,             nscharacterencodingdocumentattribute: string.encoding.utf8 anyobject         ]         {             let attributedstring = try nsattributedstring(data: encodeddata, options: attributedoptions, documentattributes: nil) //crash here             return attributedstring.string         } catch {             return self         }     }     return self } 

but in swift 3 crashes saying

*** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[_swiftvalue unsignedintegervalue]: unrecognized selector sent instance 0x6080002565f0'

anyone please suggest me need do?

i ran same problem:

let attributedoptions : [string: anyobject] = [             nsdocumenttypedocumentattribute: nshtmltextdocumenttype anyobject,             nscharacterencodingdocumentattribute: string.encoding.utf8 anyobject         ] 

here string.encoding.utf8 type check fails. use nsnumber(value: string.encoding.utf8.rawvalue)


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -