performSelectorOnMainThread strangeness
just stuck with strange thing. I have the following code:
-(void)ImageDownloadCompleat
{
[self performSelectorOnMainThread:@selector(updateImageButton:)
withObject:nil
waitUntilDone:YES];
}
-(void)updateImageButton {
NSLog(@"image OKEY");
UIImage *img = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:
@"%@/%@.jpg",pathPreview,self.idProducts]];
//images.image = img;
[images setBackgroundImage:img forState:UIControl开发者_JAVA技巧EventTouchUpInside];
[img release];
}
and it crashes with Unrecognized selector sent to instance error. what's wrong with the code above?
Thanks in advance
Since your method was declared as
-(void)updateImageButton
the corresponding selector is @selector(updateImageButton)
without a trailing colon. Change:
[self performSelectorOnMainThread:@selector(updateImageButton:)
withObject:nil
waitUntilDone:YES];
to
[self performSelectorOnMainThread:@selector(updateImageButton)
withObject:nil
waitUntilDone:YES];
and it should work.
精彩评论