PDA

View Full Version : canAdd Table Help




Demon5263
May 22, 2011, 06:25 PM
Hello, I am trying to program a table, but I need help with adding an entry, removing one is easy, and setting a default value I got down, but I want to make it where what you add in form cells 0-2 will add it to the table.

I already bound the table to the array and all the other buttons, but I think I coded it wrong.

I used a sample code to help me out, but I can't figure out how to adjust it to suit the needs of this app.

- (NSMutableDictionary *)edit:(NSDictionary *)startingValues from:(PlayersTableController *)sender
{

NSArray *editFields = [playerFormFields cells];
{
[[editFields objectAtIndex:0] setStringValue:@""];
[[editFields objectAtIndex:1] setStringValue:@""];
[[editFields objectAtIndex:2] setStringValue:@""];
}

return savedPlayerFields;
}



- (IBAction)addPlayer:(id)sender
{
NSArray *editFields = [playerFormFields cells];

[savedPlayerFields release];
savedPlayerFields = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[editFields objectAtIndex:0] stringValue], @"fieldone",
[[editFields objectAtIndex:1] stringValue], @"fieldtwo",
[[editFields objectAtIndex:2] stringValue], @"fieldthree",
nil];
[savedPlayerFields retain];
}

How can I adjust it so when I press "add", it will add to the table what you inputted into the form cells.

Thanks!