0

I am getting this error

bool _WebTryThreadLock(bool), 0x1b53d0: 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...

what is this due to ?

Thanks

Wevah
  • 28,182
  • 7
  • 83
  • 72
Biranchi
  • 16,120
  • 23
  • 124
  • 161

1 Answers1

2

From the limited information you gave, I assume that you create a UIView (or any of it'subclass) from a thread.

Try using the following instead:

[self performSelectorOnMainThread:<#(SEL)aSelector#>
                       withObject:<#(id)arg#> 
                    waitUntilDone:<#(BOOL)wait#>];

== edit ==

If that's your appDelegate which gets the callback from the thread, try adding a new method besides your callback:

- (void) setMyImage:(UIImage*)theImage { 
   ... 
   myUIImageView.image = theImage; 
   ...
} 

and call this from the thread as mentioned above:

- (void) callBackWithImage:(UIImage*)imageFromUrl { 
    [self performSelectorOnMainThread:@selector(setMyImage:) 
                           withObject:imageFromUrl 
                        waitUntilDone:NO]; 
} 
f3r3nc
  • 620
  • 7
  • 15
  • In my viewDidLoad method, i am creating a UIImageView. Then I am calling a thread , which gets the image from an URL , and inside the thread method I am setting the image for that ImageView. – Biranchi Nov 19 '09 at 03:35