Skip to content

Instantly share code, notes, and snippets.

@EchoAbstract
Created May 4, 2012 18:38
Show Gist options
  • Select an option

  • Save EchoAbstract/2596823 to your computer and use it in GitHub Desktop.

Select an option

Save EchoAbstract/2596823 to your computer and use it in GitHub Desktop.
Setter, Getter and Mapping Function
// Setter for 'coordinate' property
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate
{
// Update the coordinateArray with the coordinate information
self.coordinateArray = [NSArray arrayWithObjects:
[NSNumber numberWithDouble:newCoordinate.longitude],
[NSNumber numberWithDouble:newCoordinate.latitude], nil];
}
// Getter for 'coordinate' property
- (CLLocationCoordinate2D)coordinate
{
// Build the CLLocationCoordinate2D from our array
NSNumber *lat = [self.coordinateArray objectAtIndex:kKGALatitudeIndex];
NSNumber *lon = [self.coordinateArray objectAtIndex:kKGALongitudeIndex];
return CLLocationCoordinate2DMake(lat.doubleValue, lon.doubleValue);
}
// Kinvey: Mapping function
- (NSDictionary *)hostToKinveyPropertyMapping
{
// So it's only initialized once
static NSDictionary *mapping = nil;
if (mapping == nil){
mapping = [NSDictionary dictionaryWithObjectsAndKeys:
@"_id", @"noteId", // noteId maps to _id
@"_geoloc", @"coordinateArray", // coordinateArray maps to _geoloc
@"note", @"title", nil]; // title maps to note
}
return mapping;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment