崩溃延时

    CFRunLoopRef runLoop = CFRunLoopGetCurrent();
    CFArrayRef allModes = CFRunLoopCopyAllModes(runLoop);
    // 延时两秒退出
    double time  = 0.0;
    Bool dismissed = NO;
    while (! dismissed)
    {
        CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
        for (NSString *mode in (NSArray *)CFBridgingRelease(allModes))
        {
            CFRunLoopRunInMode((CFStringRef)CFBridgingRetain(mode), 0.001, false);
        }
        CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
        time = (end - start) + time;
        if (time >2) {
            dismissed = YES;
        }
    }
    CFRelease(allModes);

你可能感兴趣的:(崩溃延时)