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 / woot-woot.m
Created January 13, 2012 22:32
iOS Code For Kelly
///---------------------------------------------------------------------------------------
/// @name Creating Users
///---------------------------------------------------------------------------------------
+ (KCSUser *)userWithUsername: (NSString *)username password: (NSString *)password;
+ (void)checkForExistingUsernameWithBlock: (KCSUsernameCheckBlock)checkBlock;
@EchoAbstract
EchoAbstract / userTests.m
Created February 6, 2012 19:40
iOS Demo for Blog
// If you have a userController that manages a view for logging-in/creating users
- (IBAction)loginUser:(id)sender
{
// Log in the user and notify this class that logging-in completed
[KCSUser loginWithUsername:self.username.text password:self.username.password withDelegate:self];
}
- (IBAction)createUser:(id)sender
{
@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],
@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 / 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 / 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
{"_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 / 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;
@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 / 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];
}