简体   繁体   English

从CoreData制作TableView

[英]Making TableView from CoreData

I'm using CoreData for the first time, and trying to figure out how to populate a TableView using it. 我第一次使用CoreData,并试图弄清楚如何使用它填充TableView。 I have seen the sample code Apple provides, but get confused here: 我已经看到了Apple提供的示例代码,但是在这里感到困惑:

NSManagedObjectContext *moc = …; //Retrieve the main queue NSManagedObjectContext

How do I retrieve the main queue NSManagedObjectContext? 如何检索主队列NSManagedObjectContext? I've seen some say get it from AppDelegate, and I've seen others say that's not the correct way to do it, and Apple doesn't seem to use either method, and for some unknown reason just decides to omit code. 我见过有人说可以从AppDelegate获得它,我也见过有人说这不是正确的方法,而且Apple似乎没有使用这两种方法,并且出于某些未知原因,他们决定省略代码。

You can try using NSFetchedResultsController here is a complete tutorial that features it with tableView 您可以尝试使用NSFetchedResultsController这是一个完整的教程,具有tableView的功能

Swift : NSFetchedResultsController 斯威夫特: NSFetchedResultsController

Objective-C : NSFetchedResultsController & NSFetchedResultsController Objective-C: NSFetchedResultsControllerNSFetchedResultsController

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

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