【发布时间】:2016-09-01 12:52:55
【问题描述】:
我想在 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
【问题讨论】:
标签: objective-c exception-handling react-native uncaught-exception