Problems with Silver Challenge


I think I see how to get around the coordinate being a structure, but I’m getting an error when I make the archive. Code snippets below. Any thoughts?

2012-12-10 20:05:53.345 Whereami[402:11603] ViewController View Did Load
2012-12-10 20:05:57.709 Whereami[402:11603] Updated User Location in mapView
2012-12-10 20:06:06.382 Whereami[402:11603] Where: (null) <+40.75921100,-73.98463800> +/- 5.00m (speed -1.00 mps / course -1.00) @ 12/10/12 8:06:06 PM Eastern Standard Time
2012-12-10 20:06:06.383 Whereami[402:11603] We now have 2 annotations.
2012-12-10 20:06:06.383 Whereami[402:11603] Title:NY Loc:40.759211,-73.984638
2012-12-10 20:06:06.383 Whereami[402:11603] Title:Current Location Loc:40.759211,-73.984638
2012-12-10 20:06:19.576 Whereami[402:11603] -[MKUserLocation encodeWithCoder:]: unrecognized selector sent to instance 0x6d966d0
(At line:) return [NSKeyedArchiver archiveRootObject:[worldView annotations] toFile:path];

In WhereamiViewController.m:

[code]- (NSString *)annotationArchivePath {
NSArray *documentDirectories=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory=[documentDirectories objectAtIndex:0];
return [documentDirectory stringByAppendingPathComponent:@“annotation.archive”];

  • (BOOL)saveAnnotations {
    NSString *path=[self annotationArchivePath];
    return [NSKeyedArchiver archiveRootObject:[worldView annotations] toFile:path];

In BNRMapPoint.m:

[code]- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:title forKey:@“title”];
[aCoder encodeDouble:coordinate.latitude forKey:@“latitude”];
[aCoder encodeDouble:coordinate.longitude forKey:@“longitude”];

  • (id)initWithCoder:(NSCoder *)aDecoder {
    self=[super init];
    if (self) {
    [self setTitle:[aDecoder decodeObjectForKey:@“title”]];
    [self setCoordinate:CLLocationCoordinate2DMake([aDecoder decodeDoubleForKey:@“latitude”],[aDecoder decodeDoubleForKey:@“longitude”])];
    return self;

In WhereamiAppDelegate:

BOOL success=[self.viewController saveAnnotations]; if (success) { NSLog(@"Saved all worldview annotations"); } else { NSLog(@"Could not save worldview annotations"); }

So I guess I’m kind of wondering, do I need to save off worldview’s annotations into a new array first, and then archive that? I didn’t think so since the annotations were an NSArray of BNRMapPoint’s which are NSCoding compliant. Thanks for any guidance.