
NSOperationQueue* queue = [[NSOperationQueue alloc] init]; |
NSBlockOperation* bop = [NSBlockOperation blockOperationWithBlock:^{ |
NSTimer* timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(handleTime:) userInfo:nil repeats:YES]; |
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode]; |
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]]; |
|
NSLog(@"heyheyhey\n"); |
}]; |
[queue addOperation:bop]; |
/////////////////////////////////////////// |
-(void) handleTime:(id)sender{ |
NSLog(@"timer fired"); |
counter++; |
if (counter == 10){ |
NSTimer* t = sender; |
[t invalidate]; |
counter = 0; |
} |
} |




by: 发表于:2017-10-13 10:12:04 顶(0) | 踩(0) 回复
??
回复评论