Dr.Kameleon
Dr.Kameleon

Reputation: 22810

NSTableView contents not being refreshed properly

I've set up an NSTableView, whose columns are bound to an NSArrayController which gets its contents from an NSMutableArray (Matches) of NSMutableDictionary instances.

Although the thing is working, I'm experiencing this issue :

When the Matches array is updated (and this may happen quite really often), the Table View may fail to update, but when the view is redrawn (e.g. when I minimize and reload my application) the contents appear just fine.

Any ideas on that? How could I make it redraw the view / update the contents?


Hints :

Upvotes: 1

Views: 830

Answers (1)

jscs
jscs

Reputation: 64002

It sounds like you're manipulating the array directly. If so, you're doing it "behind the controller's back", so to speak. It doesn't get any kind of a notification that the array has changed.

Ideally, the array controller should be the object responsible for adding and removing things from its model; you should be using addObject: and removeObject: (or similar) on the controller, not the array itself.

Failing that, you can issue KVO notices (willChangeValueForKey: and didChangeValueForKey:) when you manipulate the array; that will make the controller pick up the changes.

Upvotes: 4

Related Questions