Closed mejibyte closed 13 years ago
Fixed!
What you have to do to overcome this is run the "setImageURL:" on the main thread, and not directly on the requestDidFinish: method. So basically just write:
-(void) requestDidFinish:(EGOHTTPRequest *)aRequest {
NSLog(@"Request to Google finished with code %d. Now loading the image...", aRequest.responseStatusCode);
[buggyImageView performSelectorOnMainThread:@selector(setImageURL:) withObject:[NSURL URLWithString:@"http://static.gowalla.com/kinds/1739-3700293ea3dcb1478289217052a588ab-100.png"] waitUntilDone:NO];
NSLog(@"And it will load.");
}
instead of
-(void) requestDidFinish:(EGOHTTPRequest *)aRequest {
NSLog(@"Request to Google finished with code %d. Now loading the image...", aRequest.responseStatusCode);
[buggyImageView setImageURL:[NSURL URLWithString:@"http://static.gowalla.com/kinds/1739-3700293ea3dcb1478289217052a588ab-100.png"]];
NSLog(@"And it will never load.");
}
Hi guys,
Suppose you have something like this, using the (great) EGOHTTPRequest library:
If you then call the "setImageURL:" message of an EGOImageView inside the "requestDidFinish:" method (that gets called when the HTTP request is finished) the image will never be loaded.
Here's a minimal application that fires the bug. Just run these steps to download the app: git clone git://github.com/andmej/EGOBug.git cd EGOBug git checkout 8ad29fe cat README
Then run it in the iPhone simulator and you will see what I'm talking about.