NSInternalConsistencyException意外开始日期NSRunLoop

时间:2016-11-10 14:16:53

标签: ios objective-c

我的app委托的几个地方(applicationWillEnterForeground,didReceiveRemoteNotification)中有以下代码。

    //create the semaphore
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

    /* ... redacted code that does some other stuff ... */

    // Wait up to 30 seconds for reauth
    int ntimeout = 3;

    //holds the thread until the dispatch_semaphore_signal(semaphore); is send
    while ((dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW)) && ( ntimeout > 0 ))
    {
        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]];

        ntimeout --;
    }

问题是我们偶尔会在[[NSRunLoop currentRunLoop] runMode行上遇到以下情况崩溃:

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x181f5edb0 __exceptionPreprocess
1  libobjc.A.dylib                0x1815c3f80 objc_exception_throw
2  CoreFoundation                 0x181f5ec80 +[NSException raise:format:]
3  Foundation                     0x1828e41c0 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]
4  UIKit                          0x187380984 _prepareForCAFlush
5  UIKit                          0x187380820 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke_2
6  CoreFoundation                 0x181f14f84 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
7  CoreFoundation                 0x181f148bc __CFRunLoopDoBlocks
8  CoreFoundation                 0x181f12820 __CFRunLoopRun
9  CoreFoundation                 0x181e3cc50 CFRunLoopRunSpecific
10 Foundation                     0x18284ccfc -[NSRunLoop(NSRunLoop) runMode:beforeDate:]

有谁知道为什么会这样?

提前致谢,

0 个答案:

没有答案