开发者

CoreData with MapKit unrecognized selector

I get the following error

2011-09-05 08:08:43.506 CaveConditions[7203:11903] -[NSManagedObject coordinate]: unrecognized selector sent to instance 0x7471910
2011-09-05 08:08:43.507 CaveConditions[7203:11903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject coordinate]: unrecognized selector sent to instance 0x7471910'

This is where I call it

NSFetchRequest *request = [[NSFetchRequest alloc] init];
    request.entity = [NSEntityD开发者_运维知识库escription entityForName:@"Cave" inManagedObjectContext:self.context];
    request.predicate = [NSPredicate predicateWithFormat:@"(latitude > 0) AND (longitude > 0)"];

    [self.mapView addAnnotations:[self.context executeFetchRequest:request error:NULL]];

It crashes at the addAnnotations line

In my Cave.h (It as a MKAnnotation delegate)

@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

In my Cave.m

- (CLLocationCoordinate2D)coordinate
{
    CLLocationCoordinate2D location;
    location.latitude = [self.latitude doubleValue];
    location.longitude = [self.longitude doubleValue];
    return location;
}

Am I missing something?

CoreData with MapKit unrecognized selector


The error suggest that Cave class is not registered as the class for the entity Cave in the data model. When you do a fetch, you get a generic NSManagedObject back instead of an instance of the Cave class.

Check the data model were has the field to put in the name for a custom NSManagedObject subclass. It is probably still set to the default.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜