LoginSignup
1
1

More than 5 years have passed since last update.

例外の詳細を出力する

Last updated at Posted at 2014-01-09

DEBUGビルドでのみ例外処理で落ちた時の詳細バグをConsoleに出力するためのコード群

通常リリースでもユーザーの環境での状態を出力して欲しければ、#ifdefは不要

Application.m
#ifdef DEBUG
static void uncaughtExceptionHandler(NSException *exception);
#endif

- (void) applicationDidFinishLaunching:(NSNotification *)notification
{
#ifdef DEBUG
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
#endif
}// end - (void) applicationDidFinishLaunching:(NSNotification *)notification

#ifdef DEBUG
static
void uncaughtExceptionHandler(NSException *exception)
{
    NSLog(@"%@", exception.name);
    NSLog(@"%@", exception.reason);
    NSLog(@"%@", exception.callStackSymbols);
}
#endif
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1