Saving core data in a thread, how to ensure its done writing before quitting?

Posted by Shizam on Stack Overflow See other posts from Stack Overflow or by Shizam
Published on 2010-04-07T21:31:21Z Indexed on 2010/04/07 21:33 UTC
Read the original article Hit count: 178

So I'm saving small images to core data which take a really short amount of time to save, like .2 seconds but I'm doing it while the user is flipping through a scroll view so in order to improve responsiveness I'm moving the saving to a thread. This works great, everything gets saved and the app is responsive. However, there is one thing in the core-data + multithreading doco that worries me:

"In Cocoa, only the main thread is not-detached. If you need to save on other threads, you must write additional code such that the main thread prevents the application from quitting until all the save operation is complete."

Ok, how do you do that? It only needs to last ~ .2 seconds and its rarely going to happen since the chance of the app quitting as something is saving is very low. How do I run something on the main thread that'll prevent the app from quitting AND not block the gui?

Thanks

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk