Created
October 23, 2014 06:41
-
-
Save ethanbing/70869e43d21c41afac67 to your computer and use it in GitHub Desktop.
崩溃后程序保持运行状态而不退出
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//崩溃后程序保持运行状态而不退出 | |
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