Created
January 3, 2013 19:36
-
-
Save anthonycvella/4446358 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
// | |
// 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