Your implementations of encodeWithCoder
and initWithCoder
for the CrumbPath
class are empty. You need to save all properties/ivars, same as you did for the Trails
object. All objects are responsible for saving their own properties/ivars with regards to NSCoding.
Just to add - you can't directly write CLLocationCoordinate2D and CGRect to disk. You'll have to break them up and reconstitute them. For example, with CGRect, you would have to encode as follows:
[aCoder encodeFloat:rect.origin.x forKey:@"x"];
[aCoder encodeFloat:rect.origin.y forKey:@"y"];
[aCoder encodeFloat:rect.size.width forKey:@"width"];
[aCoder encodeFloat:rect.size.height forKey:@"height"];
and then when decoding/init'ing, you have to reconstitute it:
CGFloat x = [aDecoder decodeFloatForKey:@"x"];
CGFloat y = [aDecoder decodeFloatForKey:@"y"];
CGFloat width = [aDecoder decodeFloatForKey:@"width"];
CGFloat height = [aDecoder decodeFloatForKey:@"height"];
self.rect = CGRectMake(x,y,width,height);