ios - Cannot invoke initializer for type 'NSAttributedString' with an argument list of type -


this question has answer here:

i followed example decode html values. to decode json parsed value: answered akashivskyy

i had code , getting following error:

let encodedstring = "the weeknd ‘king of fall’"  let encodeddata = encodedstring.datausingencoding(nsutf8stringencoding)!  let attributedoptions : [string: anyobject] = [     nsdocumenttypedocumentattribute: nshtmltextdocumenttype,     nscharacterencodingdocumentattribute: nsutf8stringencoding ]  let attributedstring = nsattributedstring(data: encodeddata, options: attributedoptions, documentattributes: nil, error: nil)!  let decodedstring = attributedstring.string  

error:

cannot invoke initializer type 'nsattributedstring' argument list of type '(data: nsdata, options: [string : anyobject], documentattributes: _, error: _)'

any appreciated suggest ay answer.

remove error option nsattributedstring initializer , add try instead:

let attributedstring = try? nsattributedstring(data: encodeddata, options: attributedoptions, documentattributes: nil) 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -