I'm trying to build a to-do-list application in Objective C but coming up short.
Posted
by lampShade
on Stack Overflow
See other posts from Stack Overflow
or by lampShade
Published on 2010-04-20T02:39:48Z
Indexed on
2010/04/20
2:43 UTC
Read the original article
Hit count: 421
I'm getting this error: -[NSCFArray insertObject:atIndex:]: attempt to insert nil
Here is the .m file:
/*
IBOutlet NSTextField *textField;
IBOutlet NSTabView *tableView;
IBOutlet NSButton *button;
NSMutableArray *myArray;
*/
#import "AppController.h"
@implementation AppController
-(IBAction)addNewItem:(id)sender
{
myArray = [[NSMutableArray alloc]init];
tableView = [[NSTableView alloc] init];
[tableView setDataSource:self];
[textField stringValue];
NSString *string = [[NSString alloc] init];
string = [textField stringValue];
[myArray addObject:string];
NSLog(@"%d",[myArray count]);
NSLog(@"%@",string);
}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [myArray count];
}
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
//NSString *data = [myArray objectAtIndex:rowIndex];
return [myArray objectAtIndex:rowIndex];
}
@end
© Stack Overflow or respective owner