当前位置: 首页 > news >正文

企业管理系统项目简介怎么写厦门网站排名优化价格

企业管理系统项目简介怎么写,厦门网站排名优化价格,商城网站建设php,优必选网站为了在iOS中捕获和处理未捕获的Objective-C异常和系统信号引起的崩溃#xff0c;可以使用NSSetUncaughtExceptionHandler和标准的Unix信号处理机制来实现。这能帮助你记录绝大部分的崩溃信息。以下是详细的实现步骤和代码示例#xff1a; 一、系统崩溃处理 通过NSSetUncaug…为了在iOS中捕获和处理未捕获的Objective-C异常和系统信号引起的崩溃可以使用NSSetUncaughtExceptionHandler和标准的Unix信号处理机制来实现。这能帮助你记录绝大部分的崩溃信息。以下是详细的实现步骤和代码示例 一、系统崩溃处理 通过NSSetUncaughtExceptionHandler捕获未处理的Objective-C异常 #import Foundation/Foundation.h #import UIKit/UIKit.hinterface UncaughtExceptionHandler : NSObject (void)installUncaughtExceptionHandler:(BOOL)install showAlert:(BOOL)showAlert;end#import UncaughtExceptionHandler.h #include libkern/OSAtomic.h #include execinfo.hNSString * const UncaughtExceptionHandlerSignalExceptionName UncaughtExceptionHandlerSignalExceptionName; NSString * const UncaughtExceptionHandlerSignalKey UncaughtExceptionHandlerSignalKey; NSString * const UncaughtExceptionHandlerAddressesKey UncaughtExceptionHandlerAddressesKey; volatile int32_t UncaughtExceptionCount 0; const int32_t UncaughtExceptionMaximum 10; static BOOL showAlertView nil;void HandleException(NSException *exception); void SignalHandler(int signal); NSString* getAppInfo(void);interface UncaughtExceptionHandler() property (assign, nonatomic) BOOL dismissed; endimplementation UncaughtExceptionHandler (void)installUncaughtExceptionHandler:(BOOL)install showAlert:(BOOL)showAlert {if (install showAlert) {[[self alloc] alertView:showAlert];}NSSetUncaughtExceptionHandler(install ? HandleException : NULL);signal(SIGABRT, install ? SignalHandler : SIG_DFL);signal(SIGILL, install ? SignalHandler : SIG_DFL);signal(SIGSEGV, install ? SignalHandler : SIG_DFL);signal(SIGFPE, install ? SignalHandler : SIG_DFL);signal(SIGBUS, install ? SignalHandler : SIG_DFL);signal(SIGPIPE, install ? SignalHandler : SIG_DFL); }- (void)alertView:(BOOL)show {showAlertView show; } (NSArray *)backtrace {void* callstack[128];int frames backtrace(callstack, 128);char **strs backtrace_symbols(callstack, frames);NSMutableArray *backtrace [NSMutableArray arrayWithCapacity:frames];for (int i 0; i frames; i) {[backtrace addObject:[NSString stringWithUTF8String:strs[i]]];}free(strs);return backtrace; }- (void)handleException:(NSException *)exception {[self validateAndSaveCriticalApplicationData:exception];if (!showAlertView) {return;}UIAlertView *alert [[UIAlertView alloc] initWithTitle:出错啦message:你可以尝试继续操作但是应用可能无法正常运行.delegate:selfcancelButtonTitle:退出otherButtonTitles:继续, nil];[alert show];CFRunLoopRef runLoop CFRunLoopGetCurrent();CFArrayRef allModes CFRunLoopCopyAllModes(runLoop);while (!self.dismissed) {for (NSString *mode in (__bridge NSArray *)allModes) {CFRunLoopRunInMode((CFStringRef)mode, 0.001, false);}}CFRelease(allModes);NSSetUncaughtExceptionHandler(NULL);signal(SIGABRT, SIG_DFL);signal(SIGILL, SIG_DFL);signal(SIGSEGV, SIG_DFL);signal(SIGFPE, SIG_DFL);signal(SIGBUS, SIG_DFL);signal(SIGPIPE, SIG_DFL);if ([[exception name] isEqual:UncaughtExceptionHandlerSignalExceptionName]) {kill(getpid(), [[[exception userInfo] objectForKey:UncaughtExceptionHandlerSignalKey] intValue]);} else {[exception raise];} }- (void)alertView:(UIAlertView *)anAlertView clickedButtonAtIndex:(NSInteger)anIndex {if (anIndex 0) {self.dismissed YES;} }- (void)validateAndSaveCriticalApplicationData:(NSException *)exception {NSString *exceptionInfo [NSString stringWithFormat:\n--------Log Exception---------\nappInfo             :\n%\n\nexception name      :%\nexception reason    :%\nexception userInfo  :%\ncallStackSymbols    :%\n\n--------End Log Exception-----,getAppInfo(), exception.name, exception.reason, exception.userInfo ?: no user info, [exception callStackSymbols]];NSLog(%, exceptionInfo);// 保存到文件等操作 }endvoid HandleException(NSException *exception) {int32_t exceptionCount OSAtomicIncrement32(UncaughtExceptionCount);if (exceptionCount UncaughtExceptionMaximum) {return;}NSArray *callStack [exception callStackSymbols];NSMutableDictionary *userInfo [NSMutableDictionary dictionaryWithDictionary:[exception userInfo]];[userInfo setObject:callStack forKey:UncaughtExceptionHandlerAddressesKey];[[[UncaughtExceptionHandler alloc] init]performSelectorOnMainThread:selector(handleException:)withObject:[NSException exceptionWithName:[exception name] reason:[exception reason] userInfo:userInfo]waitUntilDone:YES]; }void SignalHandler(int signal) {int32_t exceptionCount OSAtomicIncrement32(UncaughtExceptionCount);if (exceptionCount UncaughtExceptionMaximum) {return;}NSString* description nil;switch (signal) {case SIGABRT:description Signal SIGABRT was raised!;break;case SIGILL:description Signal SIGILL was raised!;break;case SIGSEGV:description Signal SIGSEGV was raised!;break;case SIGFPE:description Signal SIGFPE was raised!;break;case SIGBUS:description Signal SIGBUS was raised!;break;case SIGPIPE:description Signal SIGPIPE was raised!;break;default:description [NSString stringWithFormat:Signal %d was raised!, signal];}NSMutableDictionary *userInfo [NSMutableDictionary dictionary];NSArray *callStack [UncaughtExceptionHandler backtrace];[userInfo setObject:callStack forKey:UncaughtExceptionHandlerAddressesKey];[userInfo setObject:[NSNumber numberWithInt:signal] forKey:UncaughtExceptionHandlerSignalKey];[[[UncaughtExceptionHandler alloc] init]performSelectorOnMainThread:selector(handleException:)withObject:[NSException exceptionWithName:UncaughtExceptionHandlerSignalExceptionName reason:description userInfo:userInfo]waitUntilDone:YES]; }NSString* getAppInfo() {NSString *appInfo [NSString stringWithFormat:App : % %(%)\nDevice : %\nOS Version : % %\n,[[NSBundle mainBundle] objectForInfoDictionaryKey:CFBundleDisplayName],[[NSBundle mainBundle] objectForInfoDictionaryKey:CFBundleShortVersionString],[[NSBundle mainBundle] objectForInfoDictionaryKey:CFBundleVersion],[UIDevice currentDevice].model,[UIDevice currentDevice].systemName,[UIDevice currentDevice].systemVersion];return appInfo; } 在didFinishLaunchingWithOptions中调用installUncaughtExceptionHandler - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[UncaughtExceptionHandler installUncaughtExceptionHandler:YES showAlert:YES];return YES; } 二、处理Signal 在Xcode中测试Signal类型崩溃时需在调试控制台输入以下命令以允许Signal回调进入处理函数 pro hand -p true -s false SIGABRT 三、测试代码 - (void)viewDidLoad {[super viewDidLoad];[self exceptionHandlerTest1];// [self exceptionHandlerTest2];// [self exceptionHandlerTest3]; }/// 异常处理测试1 -(void)exceptionHandlerTest1{NSArray *array [tom,xxx,ooo];[array objectAtIndex:5]; }/// 异常处理测试2 -(void)exceptionHandlerTest2{[self performSelector:selector(string) withObject:nil afterDelay:2.0]; }/// 异常处理测试3 -(void)exceptionHandlerTest3{int list[2]{1,2};int *p list;free(p);p[1] 5; }
http://www.hkea.cn/news/14269524/

相关文章:

  • 网站构造360的网站怎么做
  • 怎么销售网站建设中国做外贸的网站有哪些内容
  • 昆山做网站价格短网址生成源码下载
  • 建设银行河南省分行网站京津冀协同发展国家战略
  • 北京网站建站推广宁夏政务网站建设标准
  • 怎么建设自己网站外网无法访问衡水网站建设网络公司
  • 网站主机测速为审核资质帮别人做的网站
  • 厦门网站制作软件广州大石附近做网站的公司
  • 佛山网站建设公司有哪些微信公众平台营销
  • 辽宁省建设工程招标协会网站在线设计响应式网站
  • 专业重庆房产网站建设推荐几个没封的正能量网站
  • 长沙做网站 必看 磐石网络wordpress关闭注册激活邮件
  • 珠海门户网站建设公司宝宝身上出现很多小红疹怎么办
  • 金华英文网站建设长沙好的seo外包公司
  • 阿里云自助建站教程qq音乐wordpress
  • 济南建网站公wordpress错位
  • 大汉网站开发wordpress图片搬家
  • 网络服务器与网站建设网页设计技术论文
  • 广州专业网站html个人网站
  • 网站建设及运营服务流程cms访问状态异常怎么处理
  • 西宁建设厅培训中心网站西平县住房和城乡建设局网站
  • 上海企业网站推广上海营业执照查询网上查询
  • wordpress打开网站打不开php如何做局域网的网站建设
  • 做网站是用什么软件做的oa手机版下载
  • 网站的建设与管理的心得体会购物软件app排行榜前十名
  • 贵州建设厅网站首页二级建造师成绩查询网站建设标志头像图片
  • 长沙市网站制作公司园林景观设计公司设计理念
  • 长沙住房建设部网站沈阳方正建设监理网站
  • 网站选服务器文件专业商城网站建设
  • 网站的管理跟新维护有哪些免费建造网站系统