Is there any rule that I can follow to make sure that my application only runs my own code in the main thread?
As a rule, you do not need to do anything to ensure this - your list of things is usually sufficient. If you donβt interact with some kind of API that happens to spawn a thread and run your code in the background, you will work in the main thread.
If you want to be sure, you can do something like
[self performSelectorOnMainThread:@selector(myMethod:) withObject:anObj waitUntilDone:YES];
execute the method in the main thread. (There is also the equivalent of GCD.)
Amy Worrall Jul 20 '12 at 15:36 2012-07-20 15:36
source share