Showing posts with label MKAnnotation. Show all posts
Showing posts with label MKAnnotation. Show all posts

Tuesday, September 28, 2010

Note about MKAnnotation Protocol implementation

Sometimes you just have to take things as they are given, just like that. For example adding MKAnnotation protocol support all you have to do is create an instance variable called "coordinate":
@interface MyPointItem : NSObject <MKAnnotation> {
    NSString *title;
    NSInteger distance;
    CLLocationCoordinate2D coordinate;
}
As Apple documentation says:
"An object that adopts this protocol must implement the coordinate property."
There you are. As long as you remember, WHY you have a variable called "coordinate" INSTEAD OF "location". If you don't remember and apply Natural Naming to your code, your application will start crashing horribly for mysterious reasons...