RKObjectMapping* geoPointMapping = [RKObjectMapping
mappingForClass:[CRGeoPoint class]];
geoPointMapping.setDefaultValueForMissingAttributes = YES;
[geoPointMapping mapKeyPathsToAttributes:
@"longitude", @"longitude",
@"latitude", @"latitude",
nil];
[objectManager.mappingProvider registerMapping:geoPointMapping
withRootKeyPath:@"geometry"];
RKObjectMapping* criteriaMapping = [RKObjectMapping
mappingForClass:[CRCriteria class]];
criteriaMapping.setDefaultValueForMissingAttributes = YES;
[criteriaMapping mapKeyPathsToAttributes:
@"type", @"type",
@"geometry", @"geometry",
@"fromDate", @"fromDate",
@"toDate", @"toDate",
@"radius", @"radius",
nil];
[objectManager.mappingProvider registerMapping:criteriaMapping
withRootKeyPath:@"criteria"];
But when I try and send the query (with a geometry object). I keep
getting this error:
error received Error Domain=JKErrorDomain Code=-1 "Unable to serialize
object class CRGeoPoint."
I've tried mapping the root key on the geometry to criteria.geometry
with no luck. Any hints as to what I'm doing incorrectly?
Thanks!
-warner
-warner
Here is the solution to the problem I was having, hopefully it will
help someone else.
RKObjectMapping* geoPointMapping = [RKObjectMapping
mappingForClass:[CRGeoPoint class]];
geoPointMapping.setDefaultValueForMissingAttributes = YES;
[objectManager.mappingProvider registerMapping:geoPointMapping
withRootKeyPath:@"geometry"];
// Build a serialization mapping by inverting our object mapping.
Includes attributes and relationships
RKObjectMapping* geoPointSerializationMapping = [geoPointMapping
inverseMapping];
// You can customize the mapping here as necessary --
adding/removing mappings
[[RKObjectManager sharedManager].mappingProvider
setSerializationMapping:geoPointSerializationMapping
forClass:[CRGeoPoint class]];
RKObjectMapping* criteriaMapping = [RKObjectMapping
mappingForClass:[CRCriteria class]];
criteriaMapping.setDefaultValueForMissingAttributes = YES;
[criteriaMapping mapKeyPathsToAttributes:
@"type", @"type",
@"fromDate", @"fromDate",
@"toDate", @"toDate",
@"radius", @"radius",
nil];
[criteriaMapping mapKeyPath:@"geometry" toRelationship:@"geometry"
withMapping:geoPointMapping];
[objectManager.mappingProvider registerMapping:criteriaMapping
withRootKeyPath:@"criteria"];
// Build a serialization mapping by inverting our object mapping.
Includes attributes and relationships
RKObjectMapping* criteriaSerializationMapping = [criteriaMapping
inverseMapping];
// You can customize the mapping here as necessary --
adding/removing mappings
[[RKObjectManager sharedManager].mappingProvider
setSerializationMapping:criteriaSerializationMapping
forClass:[CRCriteria class]];