0

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

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

5 Comments

Ok ... so I'm confused (no surprise) what that should be.My array controller is in MyDocument (which is a NSDocument). That's my controller. It instantiates the meeting variable which contains the personsPresent array. I've bound the array controller to that. So I'm not clear how to add objects to my array so my controller knows about them.
Please re-read my answer. You can add objects directly to the array controller by using NSArrayController's -addObject: method.
Do I need to create an iboutlet from my array controller so I can access it programatically?
Yes, if you don't have a pointer to it, you'll need to create one (in the form of an outlet if it's instantiated in your Nib). Then you can message it as needed.
Cool got both methods working, the stinky method and the best method. Thanks!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.