9

I have an NSTextAttachment which I want to show a loading image until the image has downloaded and then once it has I want to update the image.

I have all of the logic in place, except when I call textAttachment.image = image the second time nothing happens.

How can I update the NSTextAttachment once it has already been rendered by the UITextView?

Thanks!

Jason Silberman
  • 2,352
  • 6
  • 26
  • 45

1 Answers1

0

You must always update the user interface from the main thread, not from the socket thread.

Here is a Swift example:

// Update UI from main thread
dispatch_async(dispatch_get_main_queue(), {
  textAttachment.image = image
})
rjobidon
  • 2,839
  • 2
  • 28
  • 33