Here I have 2 views:
WallViewController contains MKMapView, and <
You can use PFObject.objectId to find annotation what you want.
PFObject *selectedObject = [self.objects objectAtIndex:i];
for (id annotation in wallViewController.mapView.annotations)
{
if ([annotation isKindOfClass:[PAWPost class]])
{
PAWPost *post = (PAWPost*)annotation;
if ([post.object.objectId isEqualToString:selectedObject.objectId])
{
[wallViewController.mapView selectAnnotation:annotation animated:YES];
break;
}
}
}
You can do your annotation as object that support MSAnnotation protocol. So when you select your cell - you'll exactly know what object is behind this action. And in that case you - your annotation will be exactly the object you've selected by tapping on UITableViewCell.
So - your object PAWPost just should support MKAnnotation protocol:
@interface PAWPost : NSObject <MKAnnotation>
// Interface here
@end
@implementation PAWPost
// ...
- (CLLocationCoordinate2D)coordinate {
return <#your coordinate here#>;
}
// ...
@end
P.S. You dont need to create new local instance of WallViewController class in didSelectRowAtIndexPath: method. Because at that time your WallViewController will not have MapView. Instead that - create instance of WallViewController before and use pointer to it.