避免在AppDelegate中警告“uncaughtExceptionHandler”

时间:2013-10-23 14:19:49

标签: ios objective-c c

我在AppDelegate.m中使用以下代码段来捕获异常:

void uncaughtExceptionHandler(NSException *exception)
{
    NSLog(@"CRASH: %@", exception);
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}

如何避免此警告:

Semantic Issue: No previous prototype for function 'uncaughtExceptionHandler“?

1 个答案:

答案 0 :(得分:1)

只需在.h文件中声明此方法

即可

void uncaughtExceptionHandler(NSException * exception);

或将此函数放在调用函数上。

    void uncaughtExceptionHandler(NSException *exception){
       //your code
    }

- 

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

            NSSetUncaughtExceptionHandler(&HandleExceptions);
//your code

return YES;

}