nsfetchedresultscontroller

NSFetchedResultsController - reversed NSIndexPath with multiply sections and pagination

不想你离开。 提交于 2021-02-08 04:18:11
问题 To simplify my example, I develop ChatViewController where I need to display messages grouped into sections (one section for one day). I can load more messages swiping UITableView down. I need a pagination here. Messages are displayed from the oldest (top) to the latest (bottom of the table). The obvious is that I need to fetch messages sorted by createdAt property DESCENDING . So this is how I setup my NSFetcheResultsController on viewDidLoad() : private func setupFetchedResultsController()

NSFetchedResultsController finds wrong number of objects

假装没事ソ 提交于 2021-01-27 19:04:30
问题 I'm seeing a situation where a NSFetchRequest returns a different number of objects depending on whether it's executed directly through the NSManagedObjectContext or as part of building a NSFetchedResultsController. Sample code: - (void)setupResultsController { NSError *error = nil; NSManagedObjectContext *ctx = [[DataManager sharedInstance] mainObjectContext]; // Create a fetch request and execute it directly NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription

how to group by day with core data?

£可爱£侵袭症+ 提交于 2020-06-22 12:17:47
问题 I have a Entity called deal and deal has a property called date which is the time this deal object inserted into the store. and one day may have several deal s. So I want count some data group by day, I want fetch day and countofsomething like: 2013-06-03 3 2013-06-02 4 and I don't want to use sectionPath because it only put deals into section. I know I can have this done by have another property(type:string) like dayOfTheDate which is like 2013-06-03 in each object. btw, transient property

NSFetchedResultsController returns duplicates (the same objectID and reference)

强颜欢笑 提交于 2020-05-08 11:35:44
问题 I'm experiencing a weird behaviour with NSFetchedResultsController. It is new in iOS 10. Straight to the point: fetchedObjects contains duplicate objects. This is not by any mean "duplicate" in my own criteria. They literally have the same objectIDs and the same reference. How does it happen in my app: FRC is setup and fetch performed 2 objects are fetched (in this example) Something happens in my sync layer, another object (that fetch items are in relationship with) is updated FRC calls

NSFetchedResultsController returns duplicates (the same objectID and reference)

*爱你&永不变心* 提交于 2020-05-08 11:34:46
问题 I'm experiencing a weird behaviour with NSFetchedResultsController. It is new in iOS 10. Straight to the point: fetchedObjects contains duplicate objects. This is not by any mean "duplicate" in my own criteria. They literally have the same objectIDs and the same reference. How does it happen in my app: FRC is setup and fetch performed 2 objects are fetched (in this example) Something happens in my sync layer, another object (that fetch items are in relationship with) is updated FRC calls

iOS中CoreData数据管理系列四——进行数据与页面的绑定

旧时模样 提交于 2020-03-02 18:42:08
iOS中CoreData数据管理系列四——进行数据与页面的绑定 一、引言 在上一篇博客中,我们讨论了CoreData框架中添加与查询数据的操作,事实上,在大多数情况下,这些数据都是由一个UITableView表视图进行展示的,因此,CoreData框架中还未开发者提供了一个类NSFetchedResultsController,这个类作为桥接,将视图与数据进行绑定。 添加与查询数据操作: http://my.oschina.net/u/2340880/blog/611430 。 二、进行数据初始化 NSFetchedResultsController的初始化需要一个查询请求和一个数据操作上下文。代码示例如下: //遵守协议 @interface ViewController ()<NSFetchedResultsControllerDelegate> { //数据桥接对象 NSFetchedResultsController * _fecCon; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //进行初始化操作 NSURL *modelUrl = [[NSBundle mainBundle]URLForResource:@"Model" withExtension:@

如何使用NSFetchedResultsController

生来就可爱ヽ(ⅴ<●) 提交于 2020-03-02 18:22:23
不知不觉我们已经来到了Core Data系列教程的最后一部分了,在这里我们要讨论如何使用NSFetchedResultsController来优化我们的应用,提高应用的运行速度,减少其内存占用。 你是不是已经忘记了以前讲过什么呢?我们来复习一下,在第一篇教程中:《 iOS教程:Core Data数据持久性存储基础教程 》中我们讲了如何为一个iOS程序创建一个Core Data的数据模型和测试的方法,还有我们还把这个数据模型作为数据源连接到了一个表视图上。 在第二篇教程:《 iOS教程:如何使用Core Data – 预加载和引入数据 》,我们讲了如何解析不同格式的数据文件到一个Core Data通用的SQlite数据库中,还有如何将这个数据库移植到我们的iOS项目上去,好让我们的应用有一些初始数据。 你可以从 这里 下载第二部分的源码。 为什么要使用 NSFetchedResultsController? 到目前为止,我们就像在使用SQLite3的方法一样,因为本质上Core Data就是在操作SQLite数据库,但是我们写的代码比直接使用SQLite更少,我们使用各种数据库功能也更容易。 但是,我们还有一个很好用的Core Data特性没有用上,这个特性能够很大程度上的提高我们程序的性能,他就是:NSFetchedResultsController。 现在在我们的例子程序中

UISearchDisplayController—why does my search result view contain empty cells?

限于喜欢 提交于 2020-01-31 05:32:29
问题 I am about to go out of my mind here, in my Core Data databse I have a lot of users, i have hooked the database up to a tableviewcontroller via NSFetchedResultController, and when the view loads, I see all my users, and i can perform a push to a detail viewcontroller via storyboard segue... so far so god, my tableview contains a custom cell with an image view and 2 uitextlabels that all has their tag values assigned.. Now, when I perform the search I create a new NSFetchedResultController

UISearchDisplayController—why does my search result view contain empty cells?

怎甘沉沦 提交于 2020-01-31 05:31:32
问题 I am about to go out of my mind here, in my Core Data databse I have a lot of users, i have hooked the database up to a tableviewcontroller via NSFetchedResultController, and when the view loads, I see all my users, and i can perform a push to a detail viewcontroller via storyboard segue... so far so god, my tableview contains a custom cell with an image view and 2 uitextlabels that all has their tag values assigned.. Now, when I perform the search I create a new NSFetchedResultController

NSFetchedResultsController and getting the grouping right

廉价感情. 提交于 2020-01-25 22:52:49
问题 I have the following problem. I have a UITableview that is powered by an NSFetchedResultsController. It should display let's say a projects, folders and files. There is no bigger hierarchy than that. So a project has several folders and those have several files. Now my table view should display those files, grouped by folders. So i thought my fetch requests' predicate would simply be: [NSPredicate predicateWithFormat:@"folder.project = %@", self.project]; I would then use MagicalRecord to