简体   繁体   English

检索所有NSTreeController的对象

[英]Retrieving All Of An NSTreeController's Objects

Bit of Background info, I'm using An NSOutlineView with Core Data. 背景信息,我正在将NSOutlineView与Core Data一起使用。 This Is What I'm trying to do: 这就是我想要做的:

  1. Retrieve All The objects from the Outline Views Tree Controller. 从大纲视图树控制器中检索所有对象。

  2. Retrieve the 'name' Property (Core Data) from each of these objects as a String. 从每个对象中以字符串形式检索“名称”属性(核心数据)。

  3. Finally store the Strings of the 'name' Property from all the Objects in an NSArray. 最后,将来自所有对象的'name'属性的字符串存储在NSArray中。

For extra help, here is a Picture of my Core Data Model, http://snapplr.com/xqxv 要获得更多帮助,请参见我的核心数据模型图片, http://snapplr.com/xqxv

Is this possible? 这可能吗?

You don't need to go to the treeController to get your objects, you can query your ManagedObjectContext directly. 您无需转到treeController即可获取对象,可以直接查询ManagedObjectContext。

You essentially create and execute a fetch request, which returns an NSArray. 本质上,您创建并执行获取请求,该请求将返回NSArray。 You set the predicate for the fetch in this process as well, so if you are using it to try and filter your data this is useful as well. 您还需要在此过程中为提取设置谓词,因此,如果您使用它来尝试过滤数据,这也很有用。

Here is the example from the Apple Documentation on Fetching Managed Objects . 这是Apple文档中有关获取托管对象的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM