我一直在为几个实现多级日志记录的应用程序开发框架.它主要用于内部用于测试与其他设备通信的应用程序,但也用于我们将要分发的一些应用程序中.
有没有办法捕获未捕获的异常并立即执行代码以将异常保存到日志文件中?目前,Log类只是经常写入文件,在写入失败的情况下在两个文件之间交替等等.这样可以正常工作,但是如果它可以看到发生未处理的异常,写入任何未写入的日志会很棒要记录的条目,请注意发生异常并记录其详细信息,然后允许该应用程序崩溃.
如果有一些方法来捕捉应用程序范围内未处理的异常,我会认为它会是这样的:
appDidReceiveUnhandledException:(NSException *)exception
{
//write log to disk
//append exception info to log file
//rethrow exception
}
Run Code Online (Sandbox Code Playgroud)
如果有人能够就这是否可能给我提供见解或建议,我们将不胜感激.
我正在尝试在 Xcode 中创建一个自定义模板。在我的 TemplateInfo.plist 中,对于关键选项,我粘贴了下面的代码。此模板将用于在事件发生时经常(但并非总是)使用委托的类。
我遇到的问题是最底部的值RequiredOptions. 我希望只有在选中 withProtocol 复选框时才启用文本框。但是,我无法弄清楚要使用什么值和值类型。我尝试了以下方法:
<true/> (如下) - 文本框始终处于启用状态。<string>YES</string> - 文本框始终处于禁用状态。<integer>1</integer> - 文本框始终处于启用状态。有没有人对我可以尝试的其他方法有任何想法?更好的是,有人知道 Xcode 模板的体面参考吗?
我已经通读了 Apple 的 plist 手册页和本网站上的文章。
<array>
<dict>
<key>Description</key>
<string>The name of the class to create</string>
<key>Identifier</key>
<string>productName</string>
<key>Name</key>
<string>Class</string>
<key>NotPersisted</key>
<true/>
<key>Required</key>
<true/>
<key>Type</key>
<string>text</string>
</dict>
<dict>
<key>Default</key>
<string>false</string>
<key>Identifier</key>
<string>withXIB</string>
<key>Name</key>
<string>With XIB for user interface</string>
<key>Type</key>
<string>checkbox</string>
</dict>
<dict>
<key>Description</key>
<string>Choose whether or not a delegate skeleton is …Run Code Online (Sandbox Code Playgroud)