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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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];