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

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

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -