Is it possible to load a UIImage in a background thread without causing threading problems? If not what is the best way of doing it? I'm using iOS 8. This is the way I do it right now:
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
dispatch_async(backgroundQueue, ^{
UIImage *image = [UIImage imageNamed: fileName];
// only update UI on the main thread
dispatch_async(dispatch_get_main_queue(), ^{
[self setImage: image];
});
});
See Question&Answers more detail:os