Created
May 4, 2012 18:38
-
-
Save EchoAbstract/2596823 to your computer and use it in GitHub Desktop.
Setter, Getter and Mapping Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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