views:

16

answers:

1

I' m calling doSaveItems: like

[NSThread detachNewThreadSelector:@selector(doSaveItems:) toTarget:self withObject:aObject];

doSaveItems: method has a code that references to one of my Outlets:

[uiProgressLedIdle setHidden:YES];

of course I'm setting an autorelease pool inside this method. The problem is that [uiProgressLedIdle setHidden:YES]; has no effect on my GUI when I call this method using detachNewThreadSelector:toTarget:withObject: If I call it [self doSaveItems:aObject] everything is fine and my uiProgressLedIdle is Hidden! Any suggestion of what I'm missing? Thanks!

+3  A: 

UIKit is not thread safe; always make your calls from the main thread.

of course, you're able to use multithreading in iOS - but you push your downloads and other blocking requests to secondary threads. when work is finished, use performSelectorOnMainThread: to notify the object responsible for updating the ui objects. this call will happen in the next invocation of the main thread's run loop.

Justin
Thanks! Indeed it works now as expected!
VassilisGr