Created
July 25, 2012 02:41
-
-
Save yimajo/3174070 to your computer and use it in GitHub Desktop.
未キャッチの例外をキャッチするメソッドを登録してEXC_BAD_ACCESSを保存する
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
void uncaughtExceptionHandler(NSException *exception); | |
void uncaughtExceptionHandler(NSException *exception) | |
{ | |
NSString *crashReport = [NSString stringWithFormat:@"Crash Name:%@\r\n%@\r\nStack Trace:%@",[exception name], [exception reason], [exception callStackSymbols]]; | |
NSString *crashSection = @"====Crash Report===="; | |
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; | |
[ud setObject:[NSString stringWithFormat:@"%@\r\n%@",crashSection,crashReport] forKey:@"CrashReportText"]; | |
[ud synchronize]; | |
NSLog(@"-- %@",crashReport); | |
} | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment