Skip to content

Instantly share code, notes, and snippets.

@anthonycvella
Created February 27, 2013 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonycvella/5050743 to your computer and use it in GitHub Desktop.
Save anthonycvella/5050743 to your computer and use it in GitHub Desktop.
- (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