Created
September 25, 2013 13:31
-
-
Save emarashliev/6699636 to your computer and use it in GitHub Desktop.
Rocket code
This file contains 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
- (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