nsfetchedresultscontroller

iPhone — breaking up Core Data into sections with NSFetchResultsController

血红的双手。 提交于 2019-12-03 08:46:14
问题 So I have successfully implemented Core Data to retrieve objects from a server, save them, and display them in a UITableView. However now, I wish to break these up into separate sections. I have looked for a few days now, and NSFetchedResultsController seems to confuse me, even though the way I am using it works. I have a key in my Entity called "articleSection" that is set when the item is added to Core Data with items such as "Top" "Sports" "Life". How would I go about breaking these into

NSFetchedResultsController titleForHeaderInSection with formatted NSDate

↘锁芯ラ 提交于 2019-12-03 08:21:26
In my Core Data app I am using a FetchedResultsController. Usually to set titles for headers in a UITableView you would implement the following method like so: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [[<#Fetched results controller#> sections] objectAtIndex:section]; return [sectionInfo name]; } where [sectionInfo name] returns a NSString. my sectionKeyPath is based on an NSDate and this all works fine apart from the section headers it gives me are the raw date description strings (e.g. 12/12

How to deal with many to many relationships with NSFetchedResultsController?

不问归期 提交于 2019-12-03 08:19:00
OK so I have two entities in my data model (let's say entityA and entityB), both of these entities have a to-many relationship to each other. I have setup a NSFetchedResultsController to fetch a bunch of entityA. Now I'm trying to have the section names for the tableview be the title of entityB. sectionNameKeyPath:@"entityB.title" Now this causes a problem, where by the section name returned from that relationship appears to be ({title1}) or ({title1,title2...titleN}) obviously depending on how many different entityB's are involved. This doesn't look great in a tableview and doesn't group the

NSFetchedResultsController is loading all rows even through I have batch set

你说的曾经没有我的故事 提交于 2019-12-03 08:08:14
Ok. This is the exact same question as here: Why is NSFetchedResultsController loading all rows when setting a fetch batch size? But the solution for his doesn't solve for mine. I have a screen that has several thousand records and is slow to load them all. I set the batch size to 30 (roughly three times the cells on the screen) and it still loops through and loads all the batches for some reason. Here is the code - (NSFetchedResultsController *)guestCardFetchedResultsController { if (guestCardFetchedResultsController != nil) { return guestCardFetchedResultsController; } // SELECT * from

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

筅森魡賤 提交于 2019-12-03 07:49:44
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 with a predicate, and performs the performFetch.. I then get the fetchedObjects property and it contains

Magical Record, saving, and NSFetchedResultsController

夙愿已清 提交于 2019-12-03 07:05:07
Not sure if this is an issue with the way Magical Record does saves, or I'm just making an noob mistake somewhere. I'm using an NSFetchedResultController (FRC) and UITableView to display a list of entities, when the user taps "Add" a new View Controller with an editor is pushed, a new entity is created with [MyEntity MR_createEntity] . The user can add additional entities here that are added to the main entity via a relationship. When the user taps "Save" in this View Controller the context is saved using [[NSManagedObjectContext MR_contextForCurrentThread] MR_save] The

NSFetchedResultsController returning objects with null indexPaths

為{幸葍}努か 提交于 2019-12-03 03:55:37
Details are in the comments. The following code: // Perform the fetch... NSError *error = nil; if (![[self fetchedResultsController] performFetch:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } // Confirm that objects were fetched by counting them... NSLog(@"Number of Objects = %i", [[fetchedResultsController fetchedObjects] count]); // Confirm that sections exist by counting them... NSLog(@"Numbers of Sections = %i", [[fetchedResultsController sections] count]); for (id section in [fetchedResultsController sections]) { // Count number of objects in each

iPhone: NSFetchedResultsController with delegate and data update from a separate thread

喜欢而已 提交于 2019-12-03 03:44:06
First of all, sorry for the too long question. I know that there are few questions here that discuss similar issues but none of these talks about NSFetchedResultsController with delegate together with update in separate thread. And none of the solutions has helped me. These are the existing questions: NSFetchedResultsController: using of NSManagedObjectContext during update brings to crash Determining which core Data attribute/property change triggered a NSFetchedResultsController update Core Data executeFetchRequest throws NSGenericException (Collection was mutated while being enumerated)

Illegal attempt to establish a relationship 'xyz' between objects in different contexts

一笑奈何 提交于 2019-12-03 02:36:19
问题 I am using Apple's CoreDataBooks sample application as a basis for pulling data into a secondary managed object context in the background, and then merging that data into the primary managed object context. The data I am pulling in is a Book entity with a to-one relationship with an Owner entity (called "owner"). The Owner entity has a to-many relationship with the Book (called "books"). My data is an XML document of the form: <Owner> <Name>alexpreynolds</Name> <ID>123456</ID> </Owner> <Books

Core Data Sort By Date With FetchedResultsController into sections

自闭症网瘾萝莉.ら 提交于 2019-12-03 01:41:08
I currently have a class which has a date object in it. This date object has both time and day in it. All this information gets loaded into a UITableViewCell via a NSFetchedResultsController . I need to sort the dates into sections where each section is the date without the Time. I also need each section to be sorted in itself by time. Here is what my current _fetchedResultsController looks like: [self.managedObjectContext lock]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entity" inManagedObjectContext:self