ManagedObjectContext 中选定的对象
我有一个核心数据应用程序,其中一个实体具有
主机名 用户名 属性的密码
(均为 NSString)。
然后,我使用添加和删除按钮链接了核心数据模型、数组控制器和表视图。
基本上,在这个阶段我已经编写了大约零行代码,并且该应用程序运行良好。
(这是 Mac OS X 的 Cocoa 编程第 11 章的简单版本,Hillegass)
问题是如何(以编程方式)从 ManagedObjectContext 或数组控制器获取在 tableView 中看到的选定实体/对象?
i have a core-data app with an entity that has
hostname
username
password
(all NSString) for attributes.
Then I'v linked up the core data model, the array controller, and table view with add and remove buttons.
Basically, at this stage I have written about zero lines of code and the app works great.
(This is simple version of Chapter 11 from Cocoa Programming for Mac OS X, Hillegass)
The question is how do I (programmatically) get the selected entity/object as seen in the tableView from managedObjectContext or the array controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您使用 NSArrayController 的
selectedObjects
方法。这将返回在 UI 中选择其数据的对象数组。您可以绑定它或直接调用该方法。You use the NSArrayController's
selectedObjects
method. That returns an array of the objects whose data was selected in the UI. You can bind to it or call the method directly.