1

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.

0

3 Answers 3

1

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?

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot for your help. Very insightful. I follow your advice and step into the breakpoint line. The "link.dictionary" become annotationDictionary inside the annotationLinkTarget. So I "po annotationDictionary", this time no error any more, but I only got the following information:(CGPDFDictionaryRef) $26 = 0x0000806b [no Objective-C description available]. I wonder if there is a way to print out the content of this annotationDictionary in the debugger console? thanks again for your help.
Is that your class? Provide an implementation of description and you should see it. Glad it helped, Paul.
0

Either NSLog each property of ReaderDocumentLink

Or ovveride the description mdthod in ReaderDocumentLink and use NSLog(@"%@",link):

Comments

0

I Agree with Rob as the fact that here it should work,.

But I've seen strange thing happen with 'po' especially with "dot syntax".
So if you were trying po link.dictionary and it failed I would suggest doing po [link dictionary]; With or without the ";" I don't think it make a difference. (I don't know why sometime dot syntaxe work perfectly and other time it doesn't)

Also I've seen times if I made a typo in a "po" and received an error message, no matter what I would try to "po" after would failed, so add to hit continue (or kill the app I don't recall) and go to that break point again.

And of course make sure you are doing "po" while link is in scope.

If nothing work try closing Xcode, sometimes its the solution.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.