简体   繁体   中英

Updating NSTableView after adding an item to array

I have a tableview whose columns are bound to an array controller. I'm programmatically adding items to the array:

Person is just a custom class;

personsPresent is in another class called Meeting, it's a MutableArray which contains Person objects.

Person *newPerson = [[Person alloc]init];
[[[self meeting] personsPresent] addObject:newPerson];
[[self tableView] reloadData];

This works, but the values don't show up into my table view until I sort the columns. I thought reloadData would do it for me.

In my xib, my nsarraycontroller's objectcotnroller settings is set to Class and Person. It's controller content it's bound to File Owner and it's model key path is meeting.personsPresent.

Any help would be appreciated.

Mark

You're mutating the array behind the array controller's back. Either ask the array controller to -rearrangeObjects (stinky) or use its -addObject: method (better).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM