#import "TableViewController.h"
@implementation TableViewController
- (IBAction)endCombatButton:(id)sender {
tempString = [DoaTextField stringValue];
if ([tempString isEqualToString:@"DOA"]) { [COLOR="DarkOrange"]// checks to see if the DOA was changed[/COLOR]
[errorTextField setTextColor:[NSColor redColor]];
[errorTextField setStringValue:@"SELECT DOA FIRST"];
return;
}
tempString = [levelTextField stringValue];
if ([tempString isEqualToString:@"0"]) { [COLOR="DarkOrange"]// Checks to make sure the entered a level that is not 0[/COLOR]
[errorTextField setTextColor:[NSColor redColor]];
[errorTextField setStringValue:@"ENTER LEVEL FIRST"];
return;
}
tempString = [DoaTextField stringValue];
if ([tempString isEqualToString:@"DEAD"]) { [COLOR="DarkOrange"]//Adds the 250 xp points * the level if dead[/COLOR]
hitpoints = ([levelTextField intValue] * 250) + runningCombatTotal;
}
else{
hitpoints = runningCombatTotal;
}
totalXpValue = 0;
Entry *newRecord = [[Entry alloc] init]; [COLOR="DarkOrange"]// instantiate a new record[/COLOR]
[newRecord XpEntry: hitpoints]; // add the information from the textFields
[newRecord skillEntry:[skillUsedTextField stringValue]];
[newRecord noteEntry:[noteTextField stringValue]];
[list addObject: newRecord]; [COLOR="DarkOrange"]//Adds the newRecord object to the NSMutableArray[/COLOR]
[viewTable reloadData];
[newRecord release]; [COLOR="DarkOrange"]// Release the object that I instantiated.[/COLOR]
for (int i = 0; i < [list count]; i++) { [COLOR="DarkOrange"]// I need to add up all the XP points from all the objects in the list for a grand total.[/COLOR]
Entry *tempEntry = [list objectAtIndex:i];
totalXpValue = totalXpValue + [tempEntry xp];
}
[totalXpTextField setIntValue:totalXpValue]; [COLOR="DarkOrange"]//set the total XP points to the textField[/COLOR]
[currentCombatTotalTextField setStringValue:@"0"];
[self reset];
}
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
Entry *e = [list objectAtIndex:row];
NSLog(@"skill = %@", [e skillUsed]);
NSLog(@"xp = %d", [e xp]);
[COLOR="Red"]NSLog(@"note = %@", [e note]); // here is where the problem starts. Not a CFSTtring Var?[/COLOR]
NSString *identifier = [tableColumn identifier];
return [e valueForKey:identifier];
}