I'm a little stuck on one of Hillegasses' challenges. The challenge is to make a ToDo app with NSTableView where you add an event from a textfield and extra points if it's editable. However, I can't get the events to add
Here's my appcontroller.m
At one point it would log that I added the events but still it wouldn't show, now, for some reason it doesn't do that anymore. I really appreciate you help.
Also, I've tried the addOject method but that doesn't work either.
Here's my appcontroller.m
Code:
#import "AppController.h"
@implementation AppController
-(id) init
{
[super init];
toDoList = [[NSMutableArray alloc] init];
}
-(int)numberOfRowsInTableView:(NSTableView *)tv
{
return [toDoList count];
}
-(id)tableView:(NSTableView *)tv
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row {
NSString *toDo = [toDoList objectAtIndex:row];
return toDo;
}
-(void)tableViewSelectionDidChange:(NSNotification *)notification
{
int row = [toDoTableView selectedRow];
if (row == -1) {
return;
}
NSString *selectedItem = [toDoList objectAtIndex:row];
NSLog (@"new thing to do = %@", selectedItem);
}
-(IBAction)createNewItem:(id) sender
{
NSString *item = [newItemField stringValue];
if ([item length] == 0) {
return;
}
NSInteger row = [toDoTableView selectedRow];
if (row == -1){
return;
}
{[toDoList insertObject:item atIndex:row];
}
{NSLog(@" have added %@ to list", item);
}
}
At one point it would log that I added the events but still it wouldn't show, now, for some reason it doesn't do that anymore. I really appreciate you help.
Also, I've tried the addOject method but that doesn't work either.