1

背景

  • 我在我的应用程序中使用 UKCrashReporter。

  • 我已经安装了自己的未捕获异常处理程序。

  • 我在 applicationDidFinishLaunching (1) 中设置对象 activeItemController 的 managedObjectContext

问题

如果 managedObjectContext 方法抛出异常,崩溃报告对话框只会在应用崩溃之前闪烁,因此用户永远不会报告崩溃。

我希望我的应用程序仅在报告崩溃后继续运行,而不是在窗口显示时继续运行。

我试过的

  • 如果 UKCrashReporterCheckForCrash() 是一个客观的 C 方法,我假设我可以调用 performSelectorOnMainThread:waitUntilDone:YES 但它不是。

  • 我查看了其他一些有关使用条件锁暂停应用程序的 Stack Overflow 问题,但我不明白如何将它用于 C 函数。

我将如何以一种好的方式去做这件事?人们对我有什么建议吗?任何回应将不胜感激。

编码

// In app delegate

-(void)applicationWillFinishLaunching:(NSNotification *)aNotification {
        UKCrashReporterCheckForCrash();   // A C function which then creates a window if
                                          // it detects a crash has happened.
}

-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    [activeItemController setMoContextDisk:[self managedObjectContext]];
    [activeItemController setMoContextMemory:[self managedObjectContextMemory]];
}

更新 1

有人问我有关我正在尝试做什么的更多详细信息,所以就到这里。

引发这种想法的 bug 是合并 managedObjectModels 时出现的异常。我的应用程序陷入循环,每隔几毫秒向控制台打印一次“未捕获的异常”。

当我在此异常发生之前安装未捕获的异常处理程序时,我会得到所描述的行为 - 我的应用程序会启动,短暂显示崩溃报告对话框,然后继续加载并再次崩溃。

摘要 - 我希望能够处理启动时发生的错误。

(1) 我没有使用绑定来执行此操作,因为我认为绑定会使测试类变得更有问题。

4

1 回答 1

1

I think your problem is with thinking of it as "pausing" your app. Think of it more as a different initial UI state. Your attempts to block the run loop will prevent any interactive window from ... well, being interactive. :-)

Your best bet is to show your main UI (and connect data sources, etc) only if the "am I prompting the user to submit a crash report" method says "no, go ahead and start normally". Otherwise, show your window and, when the user sends or declines to send the report, close the window and ask your app controller to continue the normal startup.

I looked at UKCrashReporterCheckForCrash() and it doesn't appear to create a window of any kind. It merely submits the crash. Could you describe what you're doing with more detail?

于 2009-12-02T16:22:40.713 回答