My main problem is storing the data which is not supported by Core Data. I already have a CLLocation property stored as a transformable attribute. I think the right approach is to declare a transient coordinate property. I keep getting EXC_BAD_ACCESS errors however.
EDIT:
My current subclass has the following interface:
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface Event : NSManagedObject {
}
@property (nonatomic, retain) NSString* title;
@property (nonatomic, retain) NSDate* timeStamp;
@property (nonatomic, retain) CLLocation *location;
@end
So I need to add
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
and
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate;
to conform to the protocol. (setCoordinate is optional, but I need it if I want to have the annotation draggable)
In core data, The location property is transformable. and I use @dynamic in the implementation to generate the accessors. I'm using this property throughout the code, so I don't want to keep this.
I think the best way to go about it is to define my coordinate property in core data as transient, but I am not definitely doing something wrong with the implementation.
- (CLLocationCoordinate2D)coordinate {
CLLocationCoordinate2D cor = CLLocationCoordinate2DMake(self.location.coordinate.latitude,
self.location.coordinate.longitude);
return cor;
}
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate {
CLLocation *newLoc = [[CLLocation alloc] initWithLatitude:newCoordinate.latitude
longitude:newCoordinate.longitude];
[self.location release];
self.location = newLoc;
}
I've tried several ways, but this is the most recent one.
Edit 2: The EXC_BAD_ACCESS in:
_kvcPropertysPrimitiveSetters