In this thread:
http://www.experts-exchange.com/Apple/Programming/Objective-C/Q_26411565.html?sfQueryTermInfo=1+10+30+setneedsdisplaiI've told to use
[theView setNeedsDisplay:YES];
in case you need to update the view. You can do it from the main thread.
Do you understand this way? Maybe, I do not understand your questions?
About the threads. Yes, any long operation in any language, for any device, should be launched in a separate thread. In iOS you can use POSIX threads and NSThread.
iOS Reference Library. Thread Management
http://developer.apple.com/iphone/library/documentation/cocoa/conceptual/Multithreading/CreatingThreads/CreatingThreads.htmlI'd say to use NSThread. Here are two simple tutorials:
http://www.xprogress.com/post-36-threading-tutorial-using-nsthread-in-iphone-sdk-objective-c/http://www.eigo.co.uk/Programming-threaded-processes-in-iPhone.aspxThe idea is simple. You create new thread:
[NSThread detachNewThreadSelector:@s
elector(th
readMethod
) toTarget:self withObject:nil];
The thread method should be like that:
- (void)threadMethod {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//Here is the code.
[pool release];
}
If you need to do something in the main thread from this new thread:
[self performSelectorOnMainThrea
d:@selecto
r(UpdateUI
Method) withObject:nil waitUntilDone:false];
In that method (it will be called in the main thread), you can update the UI.
You can try:
[theView performSelectorOnMainThrea
d:@selecto
r(setNeeds
Display:YE
S) withObject:myText waitUntilDone:NO];
(I just wrote it here without testing, but it gives an idea)