开发者

MKPlacemark declared, but not used?

i was wondering, what is the point to declare a MKPlacemark *mPlacemark; if we don't "really" use it in the code?

in the .h file :

   -(void)r开发者_StackOverfloweverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{  
    NSLog(@"Reverse Geocoder completed");  
    mPlacemark=placemark;  
    [mapView addAnnotation:placemark];  
}  

And in the .h file :

MKPlacemark *mPlacemark;

so we added the placemark to the view, but what about "mPlacemark" which not seems to be utilized ?

thanks


If the only place you're using the placemark is in that delegate method, then you don't need to declare one in the .h and you don't need to set it in the delegate method.

One reason it might be needed is if somewhere else in the code (outside the delegate method), you need to know what the "last found placemark" is. If you do need to save that reference though, it might be safer to declare it as a retain property and set it using self.mPlacemark = placemark;.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜