AFAIK, a thread can not access UI components. But I want to preload images in a background thread and then display these in an UIImageView. Do I have to use special methods to access UIImageView in the main thread then?
+1
A:
If I understood your question correctly, you're half correct. Threads can access UI components, but only the main thread can do it reliably. Your background thread can use performSelectorOnMainThread:withObject:waitUntilDone:
to call up selectors in the main thread, and from those selectors interact with the UI.
Example:
[self performSelectorOnMainThread:@selector(updateImage) withObject:nil waitUntilDone:YES];
zenzelezz
2009-10-14 11:06:17
what would waitUntilDone do?
HelloMoon
2009-10-14 12:36:47
waitUntilDone specifies whether or not the calling thread will block (halt execution) until the selector has finished running.
zenzelezz
2009-10-14 12:41:07