Created
February 27, 2013 19:15
-
-
Save anthonycvella/5050743 to your computer and use it in GitHub Desktop.
This file contains hidden or 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)loadGames { | |
NSString *userID = [Lockbox stringForKey:kUserIDKeyString]; | |
NSString *type = @"game"; | |
NSLog(@"UserID: %@", userID); | |
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: | |
userID, @"userID", | |
type, @"type", | |
nil]; | |
[NetworkingManager sendDictionary:params responseHandler:self]; | |
} | |
- (void)networkingResponseReceived:(id)response ForMessage:(NSDictionary *)message { | |
if ([[response valueForKeyPath:@"message"] isEqualToString:@"Failed"]) { | |
UIAlertView *loginAlert = [[UIAlertView alloc] initWithTitle:@"Game pull failed" message:@"An error has occured pulling games" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; | |
[loginAlert show]; | |
} else { | |
JSONResponse = [response copy]; | |
NSLog(@"JSON Response: %@", response); | |
NSLog(@"Response %@", [JSONResponse valueForKeyPath:@"games.homeSchool"]); | |
} | |
} | |
- (void)networkingResponseFailedForMessage:(NSDictionary *)message error:(NSError *)error { | |
NSLog(@"Error with request"); | |
NSLog(@"%@", [error localizedDescription]); | |
} | |
#pragma mark - Table view data source | |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | |
{ | |
// Return the number of sections. | |
return 1; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
// Return the number of rows in the section. | |
return [[JSONResponse valueForKeyPath:@"games"] count]; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
static NSString *CellIdentifier = @"Cell"; | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; | |
cell.textLabel.text = [JSONResponse valueForKeyPath:@"games.homeSchool"]; | |
return cell; | |
[tableView reloadData]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment