我想引用NSSetUncaughtExceptionHandler中的某个状态,因此不希望传入函数而是传递方法。但是怎么样?我需要引用的状态是来自react本机应用程序的回调。到目前为止我有:
#import "RNUncaughtExceptionReporter.h"
@implementation RNUncaughtExceptionReporter
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(listen:(RCTResponseSenderBlock)listener)
{
callback = listener;
NSSetUncaughtExceptionHandler(/* what goes here? */);
}
- (void) unhandledExceptionHandler(NSException *exception) {
callback(@[@"something went wrong..."]);// todo: send the detail of the exception
}
@end
答案 0 :(得分:1)
试试这个!
NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
void UncaughtExceptionHandler(NSException* exception)
{
/* do anything u want with the exception */
}