Below is a block of code that runs in a separate thread from my app's main thread. How do I get the UI to update after each button gets its thumbnail? Right now it doesn't update until the whole method finishes. The buttons are already added to a UIScrollView.
(LotsGridButton is just a UIButton with some extra properties.)
- (void)fetchThumbnails {
CCServer* server = [[CCServer alloc] init];
for (int i=0; i<[buttons count]; i++) {
LotsGridButton* button = [buttons objectAtIndex:i];
if (button.lot.thumbnail) continue;
// load the thumbnail image from the server
button.lot.thumbnail = [server imageWithPath:button.lot.thumbnailURL];
[button setImage:button.lot.thumbnail forState:UIControlStateNormal];
}
[server release];
}