Skip to content

Instantly share code, notes, and snippets.

View EchoAbstract's full-sized avatar

Brian Wilson EchoAbstract

  • TrustCloud
  • Boston, MA
View GitHub Profile
@EchoAbstract
EchoAbstract / header.m
Created May 4, 2012 18:38
KCSPersistable
@interface KGAMapNote : NSObject <MKAnnotation, KCSPersistable>
@EchoAbstract
EchoAbstract / setGetMap.m
Created May 4, 2012 18:38
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
@EchoAbstract
EchoAbstract / kinveyDelegates.m
Created May 4, 2012 18:36
Kinvey Delegate Methods
#pragma mark -
#pragma mark KCSPersistableDelegate
// Kinvey: Called when a save is complete
-(void)entity:(id)entity operationDidCompleteWithResult:(NSObject *)result
{
// Everything worked, so stop animating the activity indicator
[self.activityIndicator stopAnimating];
}
@EchoAbstract
EchoAbstract / saveNote.m
Created May 4, 2012 18:33
Saving the note to Kinvey
// KINVEY: Save this note to Kinvey
[note saveToCollection:self.mapNotes withDelegate:self];
@EchoAbstract
EchoAbstract / updateMarkers.m
Created May 4, 2012 18:32
Updating our map notes
// Called to update fetch all annotations
- (void)updateMarkers
{
// Get the current limits of the map view
MKCoordinateSpan span = self.worldView.region.span;
// KINVEY: Geo Queries use miles and there are ~69 miles per each latitudeDelta
double distanceInMiles = span.latitudeDelta*69;
CLLocationCoordinate2D mapCenter = self.worldView.centerCoordinate;
{"_id": "theArtist",
"title": "The Artist",
"year": 2011,
"director": "Michel Hazanavicius",
"awards": [{"event": "Academy Awards",
"awards": [{"name": "Best Picture", "notes": ""},
{"name": "Best Director", "notes": "Hazanavicius"},
{"name": "Best Actor", "notes": "Dujardin"},
{"name": "Best Costume Design", "notes": ""},
{"name": "Best Original Score", "notes": ""}]},
@EchoAbstract
EchoAbstract / storyWithComment.m
Created February 28, 2012 15:11
Story with Comment
// Defined somewhere in your headers
// Class for representing Stories
@interface Story : NSObject <KCSPersistable>
NSString *storyId; // In your mapping function this should map to "_id"
NSString *name;
NSString *reporter;
@end
// Class for representing comments
@EchoAbstract
EchoAbstract / DoctorREST.txt
Created February 28, 2012 03:54
Many-to-Many REST
// Find all Dr's named Joe at Mercy Hospital
GET /appdata/[appKey]/doctors/?query={"firstName": "Joe", "hospital": "Mercy"}
[{"_id": "998798ad987fe987e987bc98766",
"firstName": "Joe",
"lastName": "Brown",
"hospital": "Mercy",
"speciality": "oncology"},
{"_id": "ca6775feba86554",
@EchoAbstract
EchoAbstract / DeweyREST.txt
Created February 28, 2012 03:51
REST Requests for One-to-Many
GET /appdata/[appKey]/stories/?query={"name":"Dewey Defeats Truman"}
[{"_id": "deweyDefeatsTruman",
"name": "Dewey Defeats Truman",
"reporter": "Arthur Sears Henning"}]
GET /appdata/[appKey]/comments/?query={"storyId":"deweyDefeatsTruman"}
[{"_id": "001",
"storyId": "deweyDefeatsTruman",
@EchoAbstract
EchoAbstract / GeoQueries.m
Created February 14, 2012 03:54
Geo Queries Demonstation
// This code assumes that you have a class with a description property,
// an address property and a coordinates property. To properly enable
// geo queries, makes sure to map the "description" property to _geoloc
// in your mapping function (eg, @"_geoloc", @"description" in the dictionary
// initializer).
myPlace1.description = @"2000 sq feed small company office";
myPlace1.address = @"1 Main St, Cambridge, MA";
myPlace1.coordinates = [NSArray arrayWithObjects:
[NSNumber numberWithDouble:-71.083934],