nsfetchedresultscontroller

Why Can't I delete the bottom row of my UITableView?

时光毁灭记忆、已成空白 提交于 2019-12-05 16:05:33
When the user presses Edit, my UITableView adds an insert row at the top (with a green plus), and puts all the other rows into delete mode (red minus). Alternatively, the user can swipe-to-delete without pressing the edit button. I am using a couple of Ivars to keep track of whether the table is in edit mode from a swipe, or from pressing the edit button, and act accordingly (e.g. updating numberOfRowsInTableView: with the extra insert row when Edit has been pressed). Everything works perfectly except on thing: when in Edit mode (i.e. the user has explicitly hit the edit button, and the insert

Save order of UITableViewCells

帅比萌擦擦* 提交于 2019-12-05 12:52:11
I added the option in my tableview to sort/reorder cells. I used this tutorial: http://www.ioscreator.com/tutorials/reordering-rows-table-view-ios8-swift . Now I'd like to ask how I can save the sorting/order of the cells? I also use Core Data and the fetchedResultsController . Add an extra attribute to your Core Data model object that is used to store the sort order. For example, you could have an orderIndex attribute: class MyItem: NSManagedObject { @NSManaged var myOtherAttribute: String @NSManaged var orderIndex: Int32 } Then, use this attribute in your sort descriptor for your fetched

UITableView not updating DataSource after change to NSFetchedResultsController

送分小仙女□ 提交于 2019-12-05 11:41:21
I have an UITableView populated by a NSFetchedResultsController . The initial fetch works fine. I can add, remove, modify, etc with zero problems.. But I want to add user-defined sorting to the table. I am doing this by changing the NSFetchedResultsController to use a different sortDescriptor set, and a different sectionNameKeyPath . Here is the code where I change the fetch: -(void)changeFetchData { fetchedResultsController = nil; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Object" inManagedObjectContext

Indexing results from an NSFetchedResultsController

僤鯓⒐⒋嵵緔 提交于 2019-12-05 10:08:48
I'm having some issues with a mixed, indexed, searchable results set from an NSFetchedResults controller. I have it set up to store an indexed A-Z first initial for an entity, and then want it to display numeric first initials (i.e. # as the UILocalizedIndexCollation would do). I have already written the code that saves a "firstInitial" attribute of an Artist object as NSString @"#" if the full name started with a number, and I seem to have gotten the code half working in my UITableViewController with a customised sort descriptor. The problem is that it only works until I quit/relaunch the app

NSFetchedResultsController is driving me crazy

天涯浪子 提交于 2019-12-05 07:56:57
问题 i've been building an app since 1 month using NSFetchedResultsController and i was testing the app on the 3.1.2 SDK. The poblem is that i've been using NSFetchedResultsController everywhere in my app and was working on the 3.1.2 version of the SDK, now my client say that i should make it compatible with the 3.0 version and the deadline is almost there. But is crashing everytime i change an object handled by the contoller, the application is crashing with very weird errors. The problem occure

NSFetchedResultsController objectAtIndex, objectAtIndexPath, indexPathForObject inconsistencies

独自空忆成欢 提交于 2019-12-05 04:29:11
I have a fetched result with a single section. I am able to access the objects using [[fetchedResultsController fetchedObjects] objectAtIndex:index] for all of the objects. But it is failing when I use objectAtIndexPath like this: [fetchedResultsController objectAtIndexpath:indexPath] An error occurs after I insert an row (for one of the SearchResult objects) into the corresponding table. The object appears to be inserted into the new table correctly. After I have visually confirmed this, I select one of the rows, and then the fun begins. Here is the code where the error is occurring: - (void

NSFetchedResultsChangeUpdate fired instead of NSFetchedResultsChangeDelete

心已入冬 提交于 2019-12-05 03:28:33
I have a NSFetchedResultsController initiated in the following way: NSEntityDescription *myEntity = [NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:myEntity]; [fetchRequest setFetchBatchSize:10]; [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"wasDeleted == %@", [NSNumber numberWithBool:NO]]]; NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:)]; [fetchRequest

Core Data Fetched Results Controller and Custom Section Header

*爱你&永不变心* 提交于 2019-12-05 01:19:47
问题 I am familiar with the common and basic use of a NSFetchedResultsController managing the rows of a table, but I have an interesting problem. My data is organized as such: Schedule <--->> Day <--->> Route. I currently have a table view that has Schedules with a fetch controller managing the creation and deletion of Schedules. I now want to create a table view for Routes/Days. I would like to list a Route on every row, and create custom section headers that correspond to information within the

NSFetchedResultsController not showing updates from other contexts

不问归期 提交于 2019-12-05 01:13:12
问题 I have an NSFetchedResultsController set up to populate a UITableView, based off my 'main' NSManagedObjectContext. In a timer, I continually add objects into a separate NSManagedObjectContext, but one that shares its NSPersistantStoreCoordinator with the main context. I can see NSManagedObjectContextWillSaveNotification notifications being sent, and when I quit an restart the app, I have all the data from the previous run. However, no updates happen to the current NSFetchedResultsController.

Get parent-child array from coredata

旧时模样 提交于 2019-12-04 20:03:54
I have a CoreData model that can contain an infinite number of children. And I want to display a list of each object, indented for readability like so Object Object first child first childs children first child children Object second child Object 2 Object also has children MOre children Childs Now I come from a PHP background. and in PHP I would create a simple array which Ill traverse with some functions to build this list but this still seems stupidly hard for me. I got a flat array which basically has items like this: array.name = @"Name"; array.children = nil or coredata rows array.parent