I have seen some unusual behavior when my app responds to memory warnings – data getting out of sync primarily.
If my app receives a memory warning, will the warning pass control to the main thread?
If not, I assume I must do some data protection if the memory warning will free data that might be in use on the main thread.
I’m pretty sure that
-didReceiveMemoryWarningwill only be called on the main thread.Regardless, this is what you can do to ensure this without (potentially) deadlocking:
Call this function within
-didReceiveMemoryWarning, passing in a block with everything that you need done and then you are guaranteed to be on the main thread while executing the code in the passed-in block.