NSFetchedResultsController - 新语法?

发布于 2024-10-02 21:02:35 字数 445 浏览 3 评论 0原文

我今天开始阅读有关 NSFetchedResultsController 的内容,但遇到了一些令人困惑的语法,有人可以描述一下以下两行的含义吗?特别是 id

id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];

另外

NSManagedObjectContext *context = <#Managed object context#>;

,请确认我的理解,NSFetchedResultsController 只是一种 NSMutableArray,但具有专门用于控制核心数据的附加功能(委托消息)?

I started reading up about the NSFetchedResultsController today, but I've come across some confusing syntax, can someone please describe what the following two lines mean? Specifically the id <something>

id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];

and

NSManagedObjectContext *context = <#Managed object context#>;

Also, please confirm my understanding that the NSFetchedResultsController is simply a kind of NSMutableArray but with additional functionality (delegate messages) specifically for controlling Core Data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅渡 2024-10-09 21:02:36

id<原型> foo声明了一个变量foo,其类型是“指向符合协议PROTO的对象的指针”。这意味着只能将PROTO协议中的消息发送到foo

<#Managed Object Context#> 不是有效的 Objective-C 语法。它只是说,“粘贴代码以获取对您的 MOC 的引用。”

NSFetchedResultsControllerNSMutableArray 无关。它们唯一的共同点是都提供对有序集合的访问。 NSFetchedResultsController 位于您和托管对象上下文之间。其内容取决于上下文中的内容以及创建获取结果控制器时提供的获取请求。它调解对 MOC 的访问并尽可能使用缓存的数据。它的预期用途是作为一种将数据从 Core Data 获取到 UITableView 的简单方法。

id<PROTO> foo declares a variable foo whose type is "pointer to object conforming to protocol PROTO". This means that it is only okay to send the messages in the PROTO protocol to foo.

<#Managed Object Context#> is not valid Objective-C syntax. It's just saying, "stick the code to get a reference to your MOC here."

NSFetchedResultsController is not related to NSMutableArray. The only thing they have in common is that both provide access to ordered collections. NSFetchedResultsController stands between you and managed object context. Its content is determined by what is in the context and the fetch request supplied when the fetched results controller is created. It mediates access to the MOC and uses cached data whenever possible. Its intended use is as an easy way to get data from Core Data into a UITableView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文