【发布时间】:2016-02-01 04:55:43
【问题描述】:
正如标题所说,NSRunLoop 的 runMode:beforeDate: 不会等待。我应该怎么做才能让线程等待 NSRunLoop。
我正在后台线程上运行一个方法:
[self performSelectorInBackground:@selector(performOperation:) withObject:nil];
- (void)performSynchronousOperation:(operation *)operation
{
operationComplete = NO;
// Now wait for response
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
while (!operationComplete && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
return;
}
后台线程不会在 while 循环中等待。我有什么遗漏吗?
【问题讨论】:
标签: ios objective-c multithreading