gpt4 book ai didi

c# - 单点触控 : uncaughtExceptionHandler?

转载 作者:太空狗 更新时间:2023-10-29 22:02:16 26 4
gpt4 key购买 nike

在 MonoTouch 中,如何注册未捕获的异常处理程序(或类似函数)

在 Obj-C 中:

void uncaughtExceptionHandler(NSException *exception) {
[FlurryAnalytics logError:@"Uncaught" message:@"Crash!" exception:exception];
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
[FlurryAnalytics startSession:@" "];
....
}

最佳答案

    public delegate void NSUncaughtExceptionHandler(IntPtr exception);

[DllImport("/System/Library/Frameworks/Foundation.framework/Foundation")]
private static extern void NSSetUncaughtExceptionHandler(IntPtr handler);

// This is the main entry point of the application.
private static void Main(string[] args)
{
NSSetUncaughtExceptionHandler(
Marshal.GetFunctionPointerForDelegate(new NSUncaughtExceptionHandler(MyUncaughtExceptionHandler)));

...
}

[MonoPInvokeCallback(typeof(NSUncaughtExceptionHandler))]
private static void MyUncaughtExceptionHandler(IntPtr exception)
{
var e = new NSException(exception);
...
}

关于c# - 单点触控 : uncaughtExceptionHandler?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9491813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com