GCD sample
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
int iOctave = div(notes - 23, 12).quot;
int iclavier = div(notes - 12, 24).rem + 1;
self.scOctave.selectedSegmentIndex = iOctave;
[_soundBankPlayer queueNote:notes gain:volumn];
[_soundBankPlayer playQueuedNotes];
UIImageView *imgView = (UIImageView *)[self.view viewWithTag:iclavier + 100];
dispatch_async(dispatch_get_main_queue(), ^{
if ([setSharp containsObject:[NSNumber numberWithInt:iclavier]]) {
imgView.image = touchSharp;
} else {
imgView.image = touchClavier;
}
});
[NSThread sleepForTimeInterval:0.2];
dispatch_async(dispatch_get_main_queue(), ^{
if ([setSharp containsObject:[NSNumber numberWithInt:iclavier]]) {
imgView.image = defaultSharp;
} else {
imgView.image = defaultClavier;
}
});
});
댓글
댓글 쓰기