MonoTouch: uncaughtExceptionHandler?

前端 未结 3 487
伪装坚强ぢ
伪装坚强ぢ 2021-01-12 10:19

In MonoTouch, how do I register an uncaught exception handler (or similar function)

In Obj-C:

void uncaughtExceptionHandler(NSException *exception) {         


        
3条回答
  •  一个人的身影
    2021-01-12 10:50

    You add a try-catch handler around the code that (might) throw NSExceptions:

    try {
        FlurryAnalytics.StartSession (" ");
    } catch (MonoTouchException ex) {
        Console.WriteLine ("Could not start flurry analytics: {0}", ex.Message);
    }
    

    MonoTouch already installs an uncaught exception handler, and automatically translates those ObjectiveC exceptions to managed exceptions.

提交回复
热议问题