Size of array has non-integer type id error


#1

In my ToDo challenge I keep getting size of array has non-integer type id error. Anyone know how to solve this? Here’s my code.

ToDoAppDelegate.h

[code]#import <Cocoa/Cocoa.h>

@interface ToDoAppDelegate : NSObject
{
NSMutableArray *toDoArray;

}
@property (assign) IBOutlet NSWindow *window;

  • (IBAction)createNewItem:(id)sender;
    @property (weak) IBOutlet NSTextFieldCell *newItemField;
    @property (weak) IBOutlet NSTableView *tableView;

@end[/code]

ToDoAppDelegate.m

[code]#import “ToDoAppDelegate.h”

@implementation ToDoAppDelegate

  • (id)init
    {
    self= [super init];
    if (self) {
    NSLog(@“init”);
    }
    toDoArray = [[NSMutableArray alloc] init];

    return self;
    }

  • (NSInteger)numberOfRowsInTableView:(NSTableView *)tv
    {
    return [toDoArray count];

}

-(id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
NSString *td [[toDoArray objectAtIndex]];
return td;
}

  • (IBAction)createNewItem:(id)sender {
    NSString *string = [_newItemField stringValue];
    If([string length]==0);{

    NSLog(@“string from %@ is of zero-length”, _newItemField);
    return;
    }

    [toDoArray addObject:_newItemField];
    NSLog(@“added %@ to array”, _newItemField);
    [[self tableView] reloadData];
    }

    @end[/code]


#2

[color=#FF0000]NSString *td [[toDoArray objectAtIndex]];[/color] should be NSString *td = [toDoArray objectAtIndex];


#3

[quote=“ibex10”][quote]

-(id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
    NSString *td [[toDoArray objectAtIndex]];
    return td;
}

[/quote]
[color=#FF0000]NSString *td [[toDoArray objectAtIndex]];[/color] should be NSString *td = [toDoArray objectAtIndex];[/quote]
But then Xcode gives me more errors saying “Missing [ at start of message send expression” and similar one for the end. I don’t know why as there is already square brackets there.