At the moment, I'm getting data for the next view from the server. While this goes on, I am sho开发者_运维百科wing the user a loading indicator. After the data have been loaded, the main thread gets notified and loads the nib for the new view.
My question is: Because I already have this loading mechanism, can I safely load the nib's in the working thread and just push them from within the main thread?
UIKit
is not thread safe, so I suspect it should be pretty unsafe loading the nib in a secondary thread. Just loading the nib in a UIViewController and displaying it from the main thread could work for you and may break elsewhere.
I suppose you know about performSelectorOnMainThread:withObject:waitUntilDone
to dispatch a method from a secondary thread to the main thread. You could try and use this from your secondary thread when you want to load the nib.
EDIT:
what about preloading the nib while the working thread is retrieving the data, so that when the working thread has done, the main thread has only to display the nib views?
精彩评论