我有一个NSTimer
定义如下:
timer = [NSTimer scheduledTimerWithTimeInterval:30
target:self
selector:@selector(fooBar)
userInfo:nil
repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
fooBar
在这种情况下,我希望它使用后台线程调用回调函数。但是当我检查时,if ([NSThread mainThread])
我总是在主线程上得到它。除了从回调函数中分派线程之外,还有其他方法吗?