views:

39

answers:

1

I'm adding strings to a NSComboBox using -addItemObjectWithValue, and the items are appearing when the application is run.

However, right after adding the items, if I check the -numberOfItems, I get 1, even though there are more than that. From there, any data I try I pull back out is wrong.

I'm adding the items as part of -awakeFromNib.

I'm pretty sure it's wired correctly (the controller is a NSWindowController, I don't think this matters though?), and it's not set to use a DataSource, or AutoComplete, or anything funky.

A: 

I have the same issue. Code is:

- (void)authorListInit
{ NSError * error = nil; NSString * saveDir = [[[NSString alloc] initWithFormat:@"%@/Documents/Books",NSHomeDirectory()] autorelease]; NSArray * authorsList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:saveDir error:&error]; [AuthorNameList addItemsWithObjectValues:authorsList]; int num = [AuthorNameList numberOfItems]; NSLog(@"%i of items, originally %i",num,[authorsList count]); for(NSString * name in [AuthorNameList objectValues]) { NSLog(@"Name : %@",name); } }

AuthorNameList is the instance of NSComboBox

Output is:

Running…
2010-07-26 22:24:29.128 BookDownloader[66801:a0f] 0 of items, originally 164

Debugger stopped.
Program exited with status value:0.
Dmitry