Display the value of a variable property in LLDB debugger?

前端 未结 3 1436
感情败类
感情败类 2020-12-24 15:40

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 printe

相关标签:
3条回答
  • 2020-12-24 16:06

    Try to set this summary format in Xcodes variable view:

    section:{(int)[$VAR section]},row:{(int)[$VAR row]}
    
    0 讨论(0)
  • 2020-12-24 16:21

    I think this is a special case. The code below will work, but only if row is initialised to some value.

    (lldb) print (NSInteger)[indexPath row]
    

    I think this might be related to the fact that the row property is an extension of NSIndexPath in UIKit and is implemented as a category on that class.

    0 讨论(0)
  • 2020-12-24 16:23

    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.

    0 讨论(0)
提交回复
热议问题