简体   繁体   中英

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 (eg 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 :

  • I've also used [tableView reloadData] after updating my Matches array, but without effect.
  • This doesn't happen ALL the time, but some times... (that is it takes some patience and clicking here-and-there or minimizing the app, before the contents show up).

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.

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