线程循环

@selector(xxxThread)方法以后,在方法中添加
-(void)xxxThread
{
    NSAutoreleasePool* pool = [NSAutoreleasePool new];
    NSRunLoop* loop = [NSRunLoop currentRunLoop];

    NSTimer* timer = [[NSTimer alloc] initWithFireDate:nil
                                              interval:yourtime
                                                target:self 
                                              selector:@selector(yourFun:) 
                                              userInfo:nil
                                               repeats:YES];
    [loop addTimer:timer forMode:NSDefaultRunLoopMode];
    
    while([loop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);

    [pool release];
} 

你可能感兴趣的:(线程)