如何在Xcode中创建断点的日志消息操作? [英] how to create a breakpoint's log message action in xcode?

查看:151
本文介绍了如何在Xcode中创建断点的日志消息操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天开始观看WWDC视频,了解xCode 4中的新功能。他们提到,在断点上使用日志消息操作以及例如,在执行评估操作后自动继续能够输出变量值而不是例如一直使用NSLogs。

Been watching a WWDC video today about new features in xCode 4. They have mentioned that it a good idea to use log message actions on breakpoints along with "automatically continue after evaluation actions" enabled to output a variable's value for instance instead of using NSLogs all the time.

让我说这样的话:

NSLog(@"URL is : %@", userDocumentsURL);

我该如何编写日志消息操作以显示userDocumentsURL的值?

How would I write a log message action to display userDocumentsURL's value? Is it really a good idea to use the above method instead of NSLog?

推荐答案

创建断点日志消息操作,真的是个好主意吗?对于日志消息,包括以下内容:

Create a Breakpoint 'Log Message' action. For the log message include something like:

URL is @(char*) [[userDocumentsURL description] UTF8String]@

或者,您可以创建一个断点 Debugger command操作,类似于:

Alternatively you can create a breakpoint 'Debugger command' action similar to:

po [NSString stringWithFormat:@"URL is: %@", userDocumentsURL]

我更喜欢使用断点操作进行日志记录,因为清除一堆断点可能比删除NSLogs容易得多。以这种方式使用断点的可能缺点是(在调试过程中)断点比直接使用NSLog慢得多。

I prefer using breakpoint actions for logging, as it's arguably easier to clear out a bunch of breakpoints than it is to remove NSLogs. A possible downside to using breakpoints in this fashion is that they are significantly slower (during debugging) than a direct NSLog.

这篇关于如何在Xcode中创建断点的日志消息操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆