在LLDB调试器中显示变量属性的值?

在LLDB调试器中显示变量属性的值?

问题描述:

我正在使用带有日志消息"操作的断点,并且我想打印NSIndexPath的行.所以我尝试了:cell row @indexPath.row@,但是什么也没打印.我还尝试使用调试器命令:expr (void)NSLog(@"indexPath row:%i", indexPath.row),但出现错误:error: property 'row' not found on object of type 'NSIndexPath *'

I'm using a breakpoint with Action "Log Message", and I want to print the row of an NSIndexPath. So I tried: cell row @indexPath.row@ but nothing gets printed. I also tried using a debugger command: expr (void)NSLog(@"indexPath row:%i", indexPath.row) but I get an error: error: property 'row' not found on object of type 'NSIndexPath *'

我在做什么错了?

点语法只是编译器添加的语法糖.我一直不同意将其添加到Objective-C,但是有些人喜欢它.您要记住的是,这些点已被编译器转换为方法调用,因此当您直接在调试器中发送消息时,必须使用实际的方法调用.尝试重写您的表情:

The dot syntax is just syntactic sugar added by the compiler. I've always disagreed with adding it to Objective-C, but some people love it. What you have to remember is that these dots are getting converted into method calls by the compiler, so when you message something directly, like in the debugger, you must use the actual method call. Try rewriting your expression:

expr (void)NSLog(@"indexPath row: %ld", (long int)[indexPath row])

我不确定调试器的基本日志方法是否会执行这样的方法调用,因此您可能必须使用表达式类型.

I'm not sure if the debugger's basic log method will execute method calls like this, so you may have to use the expression type.