I need a save way to say: "iOS, I want this method to be executed a.s.a.p., but NOT in THIS run loop iteration. At the earliest in the next, but please not in this one. Thank you."
Right now I am always doing it like this:
[self performSelector:@selector(doSomethingInNextRunLoop) withObject:nil afterDelay:0];
[self doSomeOtherThings];
With the assumption that -doSomeOtherThings
will always be performed BEFORE
-doSomethingInNextRunLoop
.
The documentation says:
Specifying a delay of 0 does not necessarily cause the selector to be performed immediately. The selector is still queued on the thread’s run loop and performed as soon as possible.
So basically it can happen that the method gets called immediately as if I had just sent a direct message, causing -doSomethingInNextRunLoop
to be executed before -doSomeOtherThings
?
How can I make absolutely sure it will be called a.s.a.p. but NEVER ever in this same run loop iteration?
To clarify the wording: With run loop I mean the main thread, and the iteration in which all methods must return until the thread is ready again for new events.