开发者

calling a method that changes nib properties using detachNewThreadSelector

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 uiProgressLedIdl开发者_StackOverflow中文版e is Hidden! Any suggestion of what I'm missing? Thanks!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜