1

Following the great example of How do I decode HTML entities in swift? I have managed to decode a HTML entity. However, running my app in iOS simulator causes no errors while testing it on a real device do.

I'm getting the following error:

Thread 1: EXC_BAD_ACCESS (code=1, address=0xc)

On this line:

let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!

How do you go about solving this?

Community
  • 1
  • 1
Jonatan
  • 11
  • 3

1 Answers1

1

Probably you are not running the code in the main thread. I am not sure how it is working in the simulator. Anyway try putting that code in a main thread block like dispatch_async(dispatch_get_main_queue(), { let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil) let decodedString = attributedString?.string })

It should work properly.

Abu Saad Papa
  • 1,908
  • 15
  • 20