Add an object in NSMUtableArray


#1

Hi everybody,

First, I’m sorry for my bad English, I’m french.

In the last part of the chapter 6, I can’t add object in the NSMutableArray,
Show the addItem method:

- (IBAction)addItem:(id)sender
{
	NSString *newItem = [newItemField stringValue];
	// Is 'string' zero-length?
	if ([newItem length] == 0) {
		return;
	}
    [taskList addObject:newItem];
    [tableView reloadData];
	NSLog(@"Add an item: %@", newItem);
    NSLog(@"items count: %lu", [taskList count]);
}

And [taskList count] return 0.

I work on Xcode 4 and Mac OS 10.6.7.

HAve an idea to help me?

Thanks you for your help


#2

Is taskList nil? That would explain 0 being returned from count.