Skip to content

Instantly share code, notes, and snippets.

@ethanbing
Created October 23, 2014 06:41
Show Gist options
  • Save ethanbing/70869e43d21c41afac67 to your computer and use it in GitHub Desktop.
Save ethanbing/70869e43d21c41afac67 to your computer and use it in GitHub Desktop.
崩溃后程序保持运行状态而不退出
//崩溃后程序保持运行状态而不退出
CFRunLoopRef runLoop = CFRunLoopGetCurrent();  
    CFArrayRef allModes = CFRunLoopCopyAllModes(runLoop);  
      
    while (!dismissed)  
    {  
        for (NSString *mode in (__bridge NSArray *)allModes)  
        {  
            CFRunLoopRunInMode((__bridge CFStringRef)mode, 0.001, false);  
        }  
    }  
      
    CFRelease(allModes); 
//程序崩溃后保持运行一段时间
NSDate *date = [[NSDate date] dateByAddingTimeInterval:5];
while ([date compare:[NSDate date]] == NSOrderedDescending) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment