Skip to content

Instantly share code, notes, and snippets.

@0xjmp
Created February 15, 2013 20:24
Show Gist options
  • Save 0xjmp/4963258 to your computer and use it in GitHub Desktop.
Save 0xjmp/4963258 to your computer and use it in GitHub Desktop.
- (void)fetchChatHistoryWithBlock:(TTObjectResultBlock)block
{
NSString *path = [NSString stringWithFormat:@"/api/broadcasts/%@/chats", [self.broadcastID stringValue]];
[[TTAPIClient sharedClient] getPath:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"response object: %@", responseObject);
NSAssertIsArray(responseObject);
NSMutableArray *chats = [NSMutableArray array];
for (NSDictionary *chatDict in responseObject) {
NSDictionary *history = @{
@"user_id" : @"user_id",
@"content" : @"content",
@"broadcast_id" : @"broadcast_id"
};
[chats addObject:history];
}
if (block) block(chats, nil);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (block) block(nil, error);
}];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[self.broadcast fetchChatHistoryWithBlock:^(id responseObject, NSError *error) {
if (error) {
DDLogError(@"error retreiving chats history(%@)", [error localizedDescription]);
}
else {
[responseObject valueForKey:@""];
[responseObject valueForKey:@""];
[responseObject valueForKey:@""];
}
}];
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment