I have this code used to convert this type of characters: simbólica
to this: simbólica
.
do {
let encodedData = actualLabel.text!.data(using: String.Encoding.utf8)!
let attributedOptions: [String: AnyObject] = [
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType as AnyObject,
NSCharacterEncodingDocumentAttribute: String.Encoding.utf8 as AnyObject
]
let attributedString = try NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil)
actualLabel.text = attributedString.string
} catch {
fatalError("Unhandled error: \(error)")
}
In swift 2.0
worked correctly. But in swift 3 it returns this error to me and it does not let me continue with the execution of the app.
-[_SwiftValue unsignedIntegerValue]: unrecognized selector sent to instance 0x17404f210
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue unsignedIntegerValue]: unrecognized selector sent to instance 0x17404f210'
Doing the debug, I have reached the line where it gives an error, which is concretely:
let attributedString = try NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil)