开发者

NSFetchedResultsController - New Syntax?

I started reading up about the NSFetchedResultsController today, but I've come across some confusing syntax, can someone please describe what the following tw开发者_如何学编程o 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜