Skip to content

Instantly share code, notes, and snippets.

@anthonycvella
Created January 3, 2013 19:36
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/4446358 to your computer and use it in GitHub Desktop.
Save anthonycvella/4446358 to your computer and use it in GitHub Desktop.
//
// TradeSelectNewTableViewController.m
// WarZ Companion
//
// Created by Anthony on 1/3/13.
// Copyright (c) 2013 Anthony. All rights reserved.
//
#import "ItemDatabase.h"
#import "TradeSelectNewTableViewController.h"
@interface TradeSelectNewTableViewController ()
@end
@implementation TradeSelectNewTableViewController
@synthesize itemDatabaseArray;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
itemDatabaseArray = [NSArray arrayWithObjects:
[ItemDatabase itemOfCategory:@"weapons" name:@"Bat"],
[ItemDatabase itemOfCategory:@"weapons" name:@"Flashlight"], nil];
[self.tableView reloadData];
NSLog(@"Array: ", itemDatabaseArray);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [itemDatabaseArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//Create new Item Database Object
ItemDatabase *item = nil;
item = [itemDatabaseArray objectAtIndex:indexPath.row];
//Configure the cell
[[cell textLabel] setText:[item name]];
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
return cell;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment