【问题标题】:Using a function in NSSetUncaughtExceptionHandler在 NSSetUncaughtExceptionHandler 中使用函数
【发布时间】: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


    【解决方案1】:

    试试这个!

    NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
    
    
    void UncaughtExceptionHandler(NSException* exception)
    {
       /* do anything u want with the exception */
    }
    

    【讨论】:

      猜你喜欢
      • 2019-06-13
      • 1970-01-01
      • 2014-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-11
      • 2011-12-08
      • 1970-01-01
      相关资源
      最近更新 更多