Created
January 4, 2013 21:32
-
-
Save anthonycvella/4456268 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
#import "ItemsTableViewController.h" | |
@interface ItemsTableViewController () | |
@end | |
@implementation ItemsTableViewController | |
@synthesize categoryType, image_id, dataJSON; | |
- (id)initWithStyle:(UITableViewStyle)style | |
{ | |
self = [super initWithStyle:style]; | |
if (self) { | |
// Custom initialization | |
} | |
return self; | |
} | |
- (void)dataRequest | |
{ | |
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://"]]; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | |
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; | |
dataJSON = [json copy]; | |
NSLog(@"Data Request Step: %@", json); | |
[[self tableView] reloadData]; | |
}]; | |
} | |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | |
{ | |
return 1; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
return [dataJSON count]; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
static NSString *itemTableIdentifier = @"Cell"; | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:itemTableIdentifier]; | |
if (cell == nil ) { | |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:itemTableIdentifier]; | |
} | |
NSDictionary *items = [dataJSON objectAtIndex:indexPath.row]; | |
NSLog(@"Items: %@", items); | |
image_id = [items objectForKey:@"first"]; | |
cell.textLabel.text = image_id; | |
//cell.imageView.image = statImage; | |
//NSLog(@"State: %@", _gameState); | |
return cell; | |
} | |
/*- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
[self performSegueWithIdentifier:@"ShowSelectedServers" sender:nil]; | |
}*/ | |
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { | |
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"table_cell.png"]]; | |
} | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view. | |
NSLog(@"Test: %@", categoryType); | |
[self dataRequest]; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment