可可:核心数据+ NSTableView
我设置了一个核心数据应用程序,一切都运行良好。但有一个小问题。当我将一个新对象插入到我的实体中时,我将其转到 NSTableViewCell,在那里我可以将其编辑为我想要的文本,但有一个小问题,我可以编辑单元格,但无法取消选择它来保存它对于核心数据,它陷入编辑模式,我摆脱它的唯一方法是退出应用程序,并且它不会保存我刚刚在单元格中指定的新名称。
I have a core data app set up, and everything is working pretty well. But there is one little problem. When I insert a new object into my entity I have it go to my NSTableViewCell, where I can edit it to the text I want, but there's one little issue, I can edit the cell, but I can't deselect it to save it to core data, it's stuck in edit mode and the only way I can get out of it is by quitting the application, AND it doesn't save the new name I just gave it in my cell.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Apple 提供的 Core Data 教程中介绍了此类功能。它将让您使用
NSArrayController
,这是一个非常有用的类,用于同步视图 (NSTableView
) 和模型 (Core Data )。我相信这是一个了解其工作原理的好地方: http://developer.apple .com/cocoa/coredatatutorial/index.html
希望有帮助。
This kind of functionality is covered in the Core Data tutorials provided by Apple. It will get you to make use of the
NSArrayController
which is a very helpful class for synchronising the view (NSTableView
) and the model (Core Data).I believe this is a great place to see how this works: http://developer.apple.com/cocoa/coredatatutorial/index.html
Hope that helps.
您使用什么方法将表视图连接到核心数据存储?绑定?数据来源?
我的猜测是你根本没有实现这个。如果您刚刚开始,那么我建议实现一个 NSTableViewDataSource 实例。
http://开发人员。 apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html
What method are you using to connect the table view to the core data store? Bindings? Data Source?
My guess is that you haven't implemented this at all. If you are just getting starting then I suggest implementing an NSTableViewDataSource instance.
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html