//
//  TableViewTestAppDelegate.m
//  TableViewTest
//
//  Created by Lieven Dekeyser on 03/12/09.
//  Copyright 2009 Lieven Dekeyser. All rights reserved.
//

#import "TableViewTestAppDelegate.h"
#import "PhoneBookEntry.h"


@implementation TableViewTestAppDelegate

@synthesize window;
@synthesize tableContents;

- (id)init
{
	if (self = [super init])
	{
		tableContents = [[NSArray alloc] initWithObjects:
			[PhoneBookEntry entryWithName:@"Lieven" phone:@"+324123456789"],
			[PhoneBookEntry entryWithName:@"Test" phone:@"+3244564646546"],
			nil];
	}
	return self;
}

- (void)dealloc
{
	[tableContents release];
	[super dealloc];
}

// This code isn't necessary anymore thanks to Cocoa Bindings:
/*
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
	return [tableContents count]; 
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
	PhoneBookEntry * entry = [tableContents objectAtIndex:row];
	
	if ([tableColumn.identifier isEqual:@"name"])
	{
		return entry.name;
	}
	else if ([tableColumn.identifier isEqual:@"phone"])
	{
		return entry.phone;
	}
	else
	{
		return @"unknown";
	}
	
	// The code above could be replaced with one line thanks to Key-Value coding:
	// return [entry valueForKey:tableColumn.identifier];
}
*/

@end
