Please look to the following code, outputConsole is UITextView.
- (IBAction)buttonBuildDown
{
[self performSelectorInBackground:@selector(processBuildDown) withObject:nil];
}
- (void)processBuildDown
...
[outputConsole setText:outputText];
...
[outputConsole setText:outputText];
}
The code [outputConsole setText:outputText] raises:
Tried to obtain the web lock from a thread other than the main thread
or the web thread. This may be a result of calling to UIKit from a
secondary thread. Crashing now…
How to fix this? I need to process a long operation (about 5 sec) with informing user by UITextView about state of the process.
Thanks a lot for help!
UIKit is not thread safe, you should only update UI elements from the main thread, use NSObjects, performSelectorOnMainThread method to execute code that will run on the main thread and set the UITextViews text…
Daniel