开发者

Not found in protocol

I've subclassed MKAnnotation so that i can assign objects to annotations and then assign this object to a view controller like so:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

    PlaceDetailView *detailView = [[PlaceDetailView alloc] initWithStyle:U开发者_StackOverflowITableViewStyleGrouped];
    detailView.place = [view.annotation place];
    [self.navigationController pushViewController:detailView animated:YES];
    [detailView release];

}

This is working great but i'm having the following issues:

  • If i try and access the place getter method like so view.annotation.place i recieve an error:

    Accessing unknown place getter method

  • If i acces the place getter method like so [view.annotation place] i receive a warning:

    place not found in protocol

From my understanding this is because the place object is not defined in the MKAnnotation protocol, although i'm aware of this i'm not sure how to tell the complier that place does exist and it's not calling it blind.


If you are sure the view.annotation is always your custom class, then you can just cast it to your class:

MyAnnotation *my = (MyAnnotation *)view.annotation;
detailView.place = my.place;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜