I have an import sequence that reads from an archive, unzips the containing files and creates corresponding core data entities for each. This entire process happens in the background and a separate context has been created for each thread etc. so it all works fine.
It turns out that a desirable feature of this particular import sequence is that we allow any of the input files to be password protected (there are several of them included in an archive) so I need to check whether a file is password protected in which case the user will be prompted to enter the password via a UIAlertView
.
This is where my problem starts.
I send the UIAlertView
prompt to the main thread as I should, assign my Importer object
as the delegate
and wait for the user input.
When the user enters the password and taps OK/Cancel the delegate callback is still on the main thread so I am unable to manipulate my corresponding core data entity anymore without a lot of work (i.e. storing references to the managed object ID etc, creating new context etc).
My question:
Is it possible to go back my original background thread where the import process is working? How would I go about it?
Thanks, Rog