Programmatically update a TableView that is governed by Cocoa Bindings

萝らか妹 提交于 2019-12-08 07:06:31

You have two main options for doing this provided your array controller is bound to clientsArray.

The first way is to just use the array controller's addObject: method instead of adding objects directly to clientsArray.

The other way is to keep your current addClientFooFooey: method but wrap your existing code with these two lines:

[self willChangeValueForKey:@"clientsArray"];

[self didChangeValueForKey@"clientsArray"];

This tells the KVO system that you are making a change to the array so it will go and look at it again.

The first option is the most straightforward, but if for some reason you need to update the array directly just let KVO know you are doing it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!