Viewing NSData contents in Xcode

前端 未结 12 1977
我在风中等你
我在风中等你 2021-01-31 09:51

I am running Xcode and I would like to dump out a NSData*. The variable in question is buffer. Is there a way to do this through the UI or the GDB debugger?

12条回答
  •  离开以前
    2021-01-31 10:30

    In lldb, the following works to let you examine the contents of NSData objects:

    You can get the address of the bytes for use with various debugger commands like this:

    p (void *)[buffer bytes]
    

    You see something like this:

    (void *) $32 = 0x0b5e11f0
    

    If you know the underlying data is a string, you can do this:

    p (char *)[buffer bytes]
    

    and the debugger will output:

    (char *) $33 = 0x0b5e11f0 "This is the string in your NSData, for example."
    

提交回复
热议问题