views:

142

answers:

1

I'm developing an app where I use performSelectorInBackground to do some sync task in the background. In my code I want to be able to detect whether I'm runing in a background process. This way I can prevent alert messages which might otherwise show up.

Thanks for your help!

Markus

+2  A: 

By "background process", I assume you mean "background thread". To check if you're running on the main thread, try this:

// Some error handling code
if ([NSThread isMainThread]) {
    // Provide some sort of UI feedback
}
else {
    // Send a message to the main thread to provide feedback
}
Nick Forge
Thanks for your quick respons! That was it!
Markus