开发者

Updating NSTableView after adding an item to array

开发者 https://www.devze.com 2023-01-25 13:07 出处:网络
I have a tableview whose columns are bound to an array controller. I\'m programmatically adding items to the 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消