您的位置:首页 > 其它

实验项目3――基本线性表运算(顺序存储方式)

2011-10-16 13:55 351 查看
void SignalHandler(int signal)
{
//中断信号
}

void uncaughtExceptionHandler(NSException *exception)
{
//未捕获异常
}


安装(与全局异常断点冲突,当有这样的断点是,下面拦截函数失效)
void InstallUncaughtExceptionHandler()
{
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
signal(SIGABRT, SignalHandler);
signal(SIGILL, SignalHandler);
signal(SIGSEGV, SignalHandler);
signal(SIGFPE, SignalHandler);
signal(SIGBUS, SignalHandler);
signal(SIGPIPE, SignalHandler);
}

3.具体实例
1.http://cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html
重点在于尝试继续运行程序
告诉用户那些因为这些未拦截的异常和信号导致的崩溃,或者自己记录,甚至可以避开这样导致的崩溃.不过,如果多个信号拦截了,这可能失效.
非常推荐看看这篇文章
2.http://parveenkaler.com/2010/08/11/crashkit-helping-your-iphone-apps-suck-less/
重点在于记录异常(之后返回主线程)
- (void)pumpRunLoop
{
self.finishPump = NO;
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
CFArrayRef runLoopModesRef = CFRunLoopCopyAllModes(runLoop);
NSArray * runLoopModes = (NSArray*)runLoopModesRef;
while (self.finishPump == NO)
{
for (NSString *mode in runLoopModes)
{
CFStringRef modeRef = (CFStringRef)mode;
CFRunLoopRunInMode(modeRef, 1.0f/120.0f, false); // Pump the loop at 120 FPS
}
}
CFRelease(runLoopModesRef);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: