سؤال

I have an array which I would like to print out in a breakpoint. I have read about how to do this with @exp@, so I've created a Log Message breakpoint like so:

%B %H count: @(NSUInteger)[myArray count]@ objects: @(const char *)[[myArray description] UTF8String]@

And here's what that prints:

-methodName: 33 count: 1 objects: 0x6dec5890

From everything I've read, this should print out a string containing the objects in myArray. And yet, clearly that's not happening. What am I doing wrong?

I'm using LLDB on Xcode 5.0.2. And if it matters, the app is 32-bit.

هل كانت مفيدة؟

المحلول

This bug has been fixed in recent versions of Xcode. (I'm on 6.1.1) Now you just need to put an array's name in between @s to get the expected output. No casting needed!

%B %H count: @myArray.count@ objects: @myArray.description@

Output:

-applicationDidFinishLaunching: 1 count: 2 objects: @"(\n    one,\n    two\n)"

A little messy with the encoded newlines, but at least it works!

نصائح أخرى

Why not create a Python breakpoint action that prints the variables you care about, and then automatically continues?

I can't understand what you are doing. When I want to print or preview a variable in my code, I add a breakpoint just after my variable. When the breakpoint is reached, I just move the pointer over the name of the variable and a little window will appear where I can see the content of your variable.

Take a look at this answer: XCode 5 View Debugging Feature

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top