Why is raising an NSException not bringing down my application?

后端 未结 6 720
难免孤独
难免孤独 2020-12-30 08:23

The Problem

I\'m writing a Cocoa application and I want to raise exceptions that will crash the application noisily.

I have the following li

6条回答
  •  情歌与酒
    2020-12-30 09:15

    There turns out to be a very simple solution:

    [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @YES }];

    It does not crash your app if you use @try ... @catch.

    I can't begin to imagine why this isn't the default.

提交回复
热议问题