views:

28

answers:

1

Error- Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now

Im running a NSThread to download an image and display it, which is all in a method which is ran an other thread.

problem im getting is, when i try to set the UIImageView.image = image, it crashes because im in the 2nd thread.

How could i make it, so that this line is ran by the main thread from within the method?

Thanks

+2  A: 

First, read and understand this.

Then try something like [myView performSelectorOnMainThread: @selector(setImage:) withObject: image waitUntilDone: NO];.

Whether or not you wait until done might actually be tricky depending on how your code is threaded....

bbum