我有一个 OS X 应用程序,它使用带有两个嵌入式 NSTableViews 的拆分视图。更改一个表视图中的值应该会更改第二个中的相关值,但这不会发生。
它使用 CoreData 使用数据绑定而不是粘合代码。每个 TableView 都有一个 NSArrayController。初始窗口在第一个(左 TableView)中出现预期数据,即:
American Travel <-- selected
Browse All
Fiction
Science Fiction
美国旅游书籍对应的数据出现在第二个(右TableView),即旅游书籍列表这是因为第二个控制器的Content Set设置为:
leftController.selection.books
这意味着我将 TableColumns 绑定到正确的数据。我没有看到与在第一个 TableView 中进行新选择后无法更新第二个 TableView 的问题相关的警告。我相信系统会自动设置一个 Observer,它会观察 Left ArrayController 中选择的变化。
在 ArrayController Checked 的 Attribute Inspector 中是:
Avoid Empty Selection
Preserve Selection
Select Inserted Objects
Auto Rearrange Content
RightController 的单个 TableColumn 的值绑定 - bookList
Bind to : RightController
Controller Key : arranged Objects
ModelKey Path : name
我的问题:
我遇到的问题是,当我更改 left/first/book-types TableView中的选择时,right/second/book_names 中的数据不会改变。我在哪里寻找解决这个问题。我知道它很小,就像一个复选框。我根本找不到!
/// Begin Category.h
@class Book;
@interface Category : NSManagedObject {
}
@property (nonatomic, retain) NSSet * books;
@property (nonatomic, retain) NSString * name;// name of book_category
......
2011 年 4 月 13 日添加的更多信息
I have added a button which is connected an action in the
LeftArrayController(Category) namely, selectNext: . When I click
the button, the selection in the CATEGORY TableView does not
visibly change, but the TableView on the right (Books) does change,
as the list of books on the Right continually changes.
If I click the TableView with the mouse, no selection change is done
either in effect on the RightTableView or in the visible
sense on the Left TableView. Why is the mouseClick not effecting a
visible change int the TableViewColumn? That is, why is the mouse
unable to change selection, whereas the button is able to.
There is only one column in the TableView. In Attributes Inspector I have
tried all combination of Empty,Column and Type Select for this single selection
Table. Is there no way around using NSTableView Delegate methods to set selection?