Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EGOImaveView doesn't show its image when the "setImageURL:" method is called after a successful EGOHTTPRequest asynchronous request #4

Closed
mejibyte opened this issue Oct 20, 2010 · 1 comment

Comments

@mejibyte
Copy link
Contributor

Hi guys,

Suppose you have something like this, using the (great) EGOHTTPRequest library:

EGOHTTPRequest * request = [[EGOHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.google.com"]];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDidFinish:)];
[request startAsynchronous];

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.

@mejibyte
Copy link
Contributor Author

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.");
}

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant