我在AppDelegate.m
中使用以下代码段来捕获异常:
void uncaughtExceptionHandler(NSException *exception)
{
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}
如何避免此警告:
Semantic Issue: No previous prototype for function 'uncaughtExceptionHandler
“?
答案 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;
}