Skip to content

Instantly share code, notes, and snippets.

View achalaggarwal's full-sized avatar
🎯
Focusing

Achal Aggarwal achalaggarwal

🎯
Focusing
View GitHub Profile
@achalaggarwal
achalaggarwal / gist:1200941
Created September 7, 2011 15:48
GCChute.destroy()
//Synchronous Fetch
GCResponse *response = [GCChute findById:42];
GCChute *chute = [response object];
//Synchronous Request
if ([chute destroy]) {
//Destroyed
}
//Asynchronous Request
@achalaggarwal
achalaggarwal / gist:1200936
Created September 7, 2011 15:46
GCChute.search(key[,value])
//Synchronous Request
GCResponse *response = [GCChute searchMetaDataForKey:@"AnyKey" andValue:@"AnyValue"];
for (GCChute *chute in [response object]) {
//Individual Chutes
NSLog(@"%@", chute);
}
//Asynchronous Request
[GCChute searchMetaDataForKey:@"AnyKey" andValue:@"AnyValue" inBackgroundWithCompletion:^(GCResponse *response) {
for (GCChute *chute in [response object]) {
@achalaggarwal
achalaggarwal / gist:1200923
Created September 7, 2011 15:42
GCChute.update()
GCResponse *response = [GCChute findById:29];
GCChute *chute = [response object];
[chute setName:@"NewName"];
//Synchronous Request
if ([chute update]) {
//Updated
}
@achalaggarwal
achalaggarwal / gist:1200911
Created September 7, 2011 15:39
GCChute.find(id)
//Synchronous Request
GCResponse *response = [GCChute findById:42];
GCChute *chute = [response object];
//Asynchronous Request
[GCChute findById:42 inBackgroundWithCompletion:^(GCResponse *response) {
GCChute *chute = [response object];
}];
@achalaggarwal
achalaggarwal / gist:1200894
Created September 7, 2011 15:35
GCChute.all()
//Synchronous Request
GCResponse *_response = [GCChute all];
for (GCChute *chute in [_response object]) {
//Individual Chutes
NSLog(@"%@", chute);
}
//Asynchronous Request
[GCChute allInBackgroundWithCompletion:^(GCResponse *response) {
@achalaggarwal
achalaggarwal / gist:1200879
Created September 7, 2011 15:31
GCChute.new() and GCChute.save()
GCChute *_newChute = [GCChute new];
[_newChute setName:@"Hello World"];
//Set Permissions for a Chute
[_newChute setPermissionView:GCPermissionTypePublic];
[_newChute setPermissionAddMembers:GCPermissionTypePublic];
[_newChute setPermissionAddPhotos:GCPermissionTypePublic];
[_newChute setPermissionAddComments:GCPermissionTypePublic];
[_newChute setModeratePhotos:GCPermissionTypePublic];
@achalaggarwal
achalaggarwal / gist:1200866
Created September 7, 2011 15:26
GCRequest.delete()
NSString *_path = [[NSString alloc] init];
NSDictionary *_params = [[NSDictionary alloc] init];
GCRequest *gcRequest = [[GCRequest alloc] init];
//Synchronous Request
GCResponse *_response = [[gcRequest deleteRequestWithPath:_path andParams:_params] retain];
//Asynchronous request
@achalaggarwal
achalaggarwal / gist:1200861
Created September 7, 2011 15:24
GCRequest.put()
NSString *_path = [[NSString alloc] init];
NSDictionary *_params = [[NSDictionary alloc] init];
GCRequest *gcRequest = [[GCRequest alloc] init];
//Synchronous Request
GCResponse *_response = [[gcRequest putRequestWithPath:_path andParams:_params] retain];
//Asynchronous request
@achalaggarwal
achalaggarwal / gist:1200851
Created September 7, 2011 15:22
GCRequest.post()
NSString *_path = [[NSString alloc] init];
NSDictionary *_params = [[NSDictionary alloc] init];
GCRequest *gcRequest = [[GCRequest alloc] init];
//Synchronous Request
GCResponse *_response = [[gcRequest postRequestWithPath:_path andParams:_params] retain];
//Asynchronous request
@achalaggarwal
achalaggarwal / gist:1200842
Created September 7, 2011 15:16
GCRequest.get()
NSString *_path = [[NSString alloc] init];
GCRequest *gcRequest = [[GCRequest alloc] init];
//Synchronous Request
GCResponse *_response = [[gcRequest getRequestWithPath:_path] retain];
//Asynchronous request
[gcRequest getRequestInBackgroundWithPath:_path withResponse:^(GCResponse *response) {
NSLog(@"%@", response);