How to use Xcode 4 breakpoint actions
Asked Answered
I

2

6

I want to use Xcodes capabilities to log certain data. In fact it should be quite simple to achive something similar to

NSLog(@"Size: %@", NSStringFromRect(self.view.frame));

with the Log Message action of a breakpoint. I tried variations of this:

Size: @NSStringFromRect([[self view] frame])@

but failed.

I already searched the Xcode documentation and was surprised how bad that feature is documented. The only bit of information I was able to find was about how configuring at sound playing action when hitting breakpoints.

Ibarra answered 6/12, 2011 at 12:3 Comment(2)
So you want to log a rect. What's the relation with breakpoints?Bozcaada
You can setup breakpoints which automatically continue after evaluation. According to an Apple evangelist this method of logging debug data is preferred over littering your code with a bunch of NSLog statements. It also has the advantage of organizing your log statements via the breakpoint view in Xcode (you can share these breakpoints to separate the breakpoints from »real« ones).Ibarra
W
8

How about

Size: @(CGRect)[[self view] frame]@
Weever answered 6/12, 2011 at 12:52 Comment(0)
S
3

Another solution would be:

Size: @(const char *)[[[[some objects] object] description] UTF8String]@

The output is not as nice as the one in fourplusone answer but it will work with all objects which provide a good description.

Shiest answered 6/12, 2011 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.