在主从窗口视图中添加明细记录
我将以“Cocoa 的全新内容”作为序言——我的应用程序上有一个主/详细信息页面:可能有一个或多个联系人(即父母、亲戚等)的学生。我有一个学生实体和一个联系人实体,其中学生实体中有一个名为“联系人”的关系字段,而联系人实体中有另一个名为“学生”的关系字段。该视图有一个用于学生的 TableView 和一个用于联系人的 TableView,并带有添加和删除按钮,用于为表中突出显示的学生添加联系人。有称为 Students 和 Contacts 的 NSArrayController 对象来管理实体。学生绑定到文件所有者(NSDocument)ManagedObjectContext,并且学生姓名在该 TableView 中显示良好。联系人数组控制器内容集绑定到 Students.Selection.Contact(学生实体中的一个关系字段)。
添加按钮连接到联系人数组控制器中的 add: 方法,删除按钮绑定到单击“添加”按钮不会执行任何操作,并且日志上没有错误,因此我不确定哪里缺少连接有什么想法吗?
I'll preface with "Brand new to Cocoa" -- I have a master/detail page on my app: Students that may have one or several contacts (i.e. parents, relatives, etc). I have a Student entity and a Contact entity with a relationship field called "contact" in the Student entity and another relationship field called "student" in the Contact entity. The view has a TableView for the students and a TableView for the contacts with add and delete buttons to add a contact for the student that's highlighted in the table. There are NSArrayController objects called Students and Contacts to manage the entities. Students is bound to the File Owner (the NSDocument) ManagedObjectContext and the student name shows up fine in that TableView. The Contacts array controller Content Set is bound to Students.Selection.Contact (a relationship field in the Students entity.
The Add button is connected to the add: method in the Contacts array controller and the Delete button is bound to the remove: method in the Contact array controller. Clicking the Add button doesn't do anything -- and no errors on the log, so I'm not sure where the connection is missing. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了——缺少一个绑定:)
I figured it out -- there was a binding missing :)