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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -