Skip to content

Instantly share code, notes, and snippets.

@emarashliev
Created September 25, 2013 13:31
Show Gist options
  • Save emarashliev/6699636 to your computer and use it in GitHub Desktop.
Save emarashliev/6699636 to your computer and use it in GitHub Desktop.
Rocket code
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *resources = [[NSMutableArray alloc] init];
NSURL *URL = [NSURL URLWithString:@"http://localhost:8080"];
AFHTTPClient *manager = [[AFHTTPClient alloc] initWithBaseURL:URL];
[manager GET:@"/messages" parameters:nil success:^(NSHTTPURLResponse *response, id responseObject) {
[resources addObjectsFromArray:responseObject[@"resources"]];
[manager SUBSCRIBE:@"/messages" usingBlock:^(NSArray *operations, NSError *error) {
for (AFJSONPatchOperation *operation in operations) {
switch (operation.type) {
case AFJSONAddOperationType:
[resources addObject:operation.value];
NSLog(@"%@", operation.value);
break;
default:
break;
}
}
} error:nil];
} failure:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment