开发者

iPhone NSThread Help

开发者 https://www.devze.com 2023-03-31 17:48 出处:网络
I\'m having some problems with my thread. Currently, the view brought up by showInstructions is disabled until the thread is done... how can I make it interactive while the thread is going on?

I'm having some problems with my thread. Currently, the view brought up by showInstructions is disabled until the thread is done... how can I make it interactive while the thread is going on?

Thanks in advance!

 [self performSelectorOnMainThread:@selector(loadEverything) withObject:self waitUntilDone:YES];


    -(void)loadEverything {    
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

        [self performSelector:@selector(showInstructions)];
        [self performSelector:@selector(loadStats)];
        [s开发者_StackOverflowelf performSelector:@selector(animate_sideBTN)];
        [self performSelector:@selector(loadNIBs)];
        [self performSelector:@selector(incrementStats)];

        [NSThread detachNewThreadSelector:@selector(loadMap) toTarget:self withObject:nil];

        [[self.view viewWithTag: 123] removeFromSuperview];
        [pool drain];
        }


Please try calling -(void)loadEverything in "performSelectorOnMainThread" and from that call [NSThread detachNewThreadSelector:] for operation which are not affecting UI components and [self performSelector] for which are affecting UI components.


I think you should learn some GCD and do the same code inside a block. Or use an NSOperation… Avoid threads if possible.

0

精彩评论

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