Search code examples
iphoneobjective-ccocoa-touchmkannotation

Annotation Sub Class custom initWithCoordinate


I've subclassed MKAnnotation so that i can assign objects to each annotation, this is so that when the rightCalloutAccessoryView is clicked i can push a navigation controller with the object passed to it and display the objects data in another view.

This all works great apart from one thing, i've extended upon initWithCoordinate like so:

-(id)initWithCoordinate:(CLLocationCoordinate2D)coord andObject:(NSManagedObject *)object {

    [self setPlace:object];

    coordinate = coord;
    title = [place valueForKey:@"name"];
    subtitle = [place valueForKey:@"address"];

    return self;

}

Although everything is working great i'm recieving the warning:

NO '-initWithCoordinate:andObject:' method found

Which means i'm doing something wrong somewhere, what is the correct way to go about adding upon initWithCoorinate?


Solution

  • Put the prototype -(id)initWithCoordinate:(CLLocationCoordinate2D)coord andObject:(NSManagedObject *)object in .h file.