CoreData 和可可的数据绑定
我正在使用 CoreData 和 DataBindings 开发一个小型 DB 图书管理 Mac OSX 应用程序。 我有一个包含所有书籍作者的 TableView。 我想要另一个 TableView 来表示上表中选择的作者所写的所有书籍...... 这两个表都由 IB 中的两个 ArrayController 管理。 我的问题是我不知道如何使用第一个表选择来过滤第二个表/ArrayController。 我还必须在过滤后的 ArrayController 中插入一本新书。
我能做到? 多谢!
I'm developping a little DB book management Mac OSX app with CoreData and DataBindings.
I have a TableView with all the book authors.
I would another TableView that rapresent all books written by the author selected in the previous table...
The both tables are managed with two ArrayController in IB.
My problem is that I don't know how to filter the second table / ArrayController with the first table selection.
I must also insert a new book in the filtered ArrayController.
I can do it?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该阅读有关 NSPredicate< /a>,阵列控制器支持它们过滤内容。要添加新书,您应该重写 ArrayController 的“add:”方法(它的子类),或者在窗口控制器中的某个位置编写一个自定义方法,该方法将构造新对象并使用 addObject: 调用将其推送到 ArrayController 中。
You should read about NSPredicate, array controllers supports them for filtering the content. To add a new book you should override "add:" method of the ArrayController (subclass it) or write a custom method somewhere in the window controller that will construct new object and push it into the ArrayController with addObject: call.
我实际上写了一个可能有帮助的教程 http://themikeswan.wordpress.com /2009/05/22/7/ 简短的答案是,您绑定书籍表的数组控制器,以从其他数组控制器的选择中获取其内容集。然后,书籍数组控制器将从作者数组控制器中选择的任何作者那里获取其项目。您还应该只需要添加一个用于添加书籍的按钮并将其连接到书籍数组控制器的 add: 方法(我还没有尝试过这个,但理论上它应该有效,我不确定作者关系是否会不过要正确设置)。
I actually wrote a tutorial that might be of help http://themikeswan.wordpress.com/2009/05/22/7/ the short answer is that you bind the array controller for the book table to get it's Content Set from the selection of the other array controller. The book array controller would then get it's items from whichever author is selected in the author array controller. You should also just have to add a button for adding books and connect it to the book array controller's add: method (I have not tried this as of yet, but in theory it should work, I'm not sure if the author relationship will get properly set though).