Closed 3lvis closed 7 years ago
When using sortDescriptors with sectionName, the sectioName descriptor has to be in the top, this is a stupid bug by NSFetchedResultsController.
Wrong:
let request: NSFetchRequest = NSFetchRequest(entityName: "User") request.sortDescriptors = [ NSSortDescriptor(key: "count", ascending: true), NSSortDescriptor(key: "name", ascending: true), NSSortDescriptor(key: "firstLetterOfName", ascending: true) ] let dataSource = DATASource(tableView: self.tableView, cellIdentifier: CustomCell.Identifier, fetchRequest: request, mainContext: self.dataStack!.mainContext, sectionName: "firstLetterOfName") { cell, item, indexPath in }
Correct:
let request: NSFetchRequest = NSFetchRequest(entityName: "User") request.sortDescriptors = [ NSSortDescriptor(key: "firstLetterOfName", ascending: true), NSSortDescriptor(key: "count", ascending: true), NSSortDescriptor(key: "name", ascending: true) ] let dataSource = DATASource(tableView: self.tableView, cellIdentifier: CustomCell.Identifier, fetchRequest: request, mainContext: self.dataStack!.mainContext, sectionName: "firstLetterOfName") { cell, item, indexPath in }
Maybe it's obvious, at least it wasn't obvious for me. 😟
Doing some spring cleaning, please open a new issue if you still want to do this.
When using sortDescriptors with sectionName, the sectioName descriptor has to be in the top, this is a stupid bug by NSFetchedResultsController.
Wrong:
Correct: