Getting a Link object from an Annot object

Q:

I’ve run into a problem trying to respond to tapping on links in a PDF. I do the following code:

UITouch *touch = [touches anyObject];
CGPoint down = [touch locationInView:m_pdfViewCtrl];

Annot *annotation = nil;
@try {
[m_pdfViewCtrl DocLockRead];

annotation = [[m_pdfViewCtrl GetAnnotationAt:down.x y:down.y] retain];

if ( [annotation IsValid]) {
NSLog( @" Annotation: %@ Type: %i", annotation, [annotation GetType]);
if ([annotation GetType] == e_Link) {

// link
Link linkAnnot = (Link)annotation;

Action *action = [linkAnnot GetAction];

But on the last line I get this log statement:

2013-10-14 07:33:48.848 Soonr[2136:c07] -[Annot GetAction]: unrecognized selector sent to instance 0x15af0760

-[Annot GetAction] is defined in the PDFNetOBJC.h:2804 header file, am I attacking this incorrectly?

A:

Unfortunately you can’t cast an Annot to a Link as you are doing. (The Annot is of type e_Link, but it is not actually a Link object.) Instead you need to do Link* linkAnnot = [[Link alloc] initWithAnn:annotation];