Created
February 15, 2013 20:24
-
-
Save 0xjmp/4963258 to your computer and use it in GitHub Desktop.
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)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); | |
}]; | |
} |
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)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