I have the following piece of code in xcode and would like to inspect the contents of “link” which is a local object “ReaderDocumentLink *link” declared in the for loop and I set breakpoint at the line
“result = [self annotationLinkTarget:link.dictionary];” as show below:
-(id)singleTap:(UITapGestureRecognizer *)recognizer
{
id result = nil; // Tap result object
if (recognizer.state == UIGestureRecognizerStateRecognized)
{
if (_links.count > 0) // Process the single tap
{
CGPoint point = [recognizer locationInView:self];
for (ReaderDocumentLink *link in _links) // Enumerate links
{
if (CGRectContainsPoint(link.rect, point) == true) // Found it
{
result = [self annotationLinkTarget:link.dictionary];
break;
}
}
}
}
return result;
}
I tried “po link” and it doesn’t work. (it reports error as below:
error: ‘link’ has unknown type; cast it to its declared type to use it
error: 1 errors parsing expression
So what shall I do to print out the details in the “link” object? including the contents of link.dictionary as well. Thanks.
Xcode added the notion of a log breakpoint. That’s what the OP is asking for. And he’s come upon one of it’s biggest stopping points: po has to be turned loose on a type that has a description method that does something. I don’t use these a lot for this very reason: there are too many integral types still in the code that you want to inspect.
You could turn the item into an object inside the breakpoint, but that’s a nuisance too, e.g. [NSNumber numberWithFloat:5.5] and then po that.
Link should work here. Maybe you are trying to do po on a line where it’s out of scope?