开发者

calling a method that changes nib properties using detachNewThreadSelector

开发者 https://www.devze.com 2023-01-22 12:33 出处:网络
I\' m calling doSaveItems: like [NSThread detachNewThreadSelector:@selector(doSaveItems:) toTarget:self withObject:aObject];

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

精彩评论

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

关注公众号