1

Am calling a method in background queue as,

dispatch_async(backgroundQueue, ^(void) {
[self loadImage:imageUrlString];
});
 // This is the loadImage method:

- (void)loadImage:(NSString *)imageUrlString
{        
    // calling a method in main queue to add a preloader

    dispatch_async(dispatch_get_main_queue(), ^(void) {


                  [self addPreloader];
    });

    // converting the url content to NSData
    NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrlString]];

    // calling a method in main queue to load the image with imageData.
    dispatch_async(dispatch_get_main_queue(), ^(void) {
        [self setImage:imageData];
    });  
}

But the app crashes. This is my Crash log: bool _WebTryThreadLock(bool), 0xc9a5010: 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...

4

0 に答える 0