Skip to content

Instantly share code, notes, and snippets.

@premedios
Last active November 29, 2017 13:23
Show Gist options
  • Save premedios/60f50a6027532536574f8fb6c760741f to your computer and use it in GitHub Desktop.
Save premedios/60f50a6027532536574f8fb6c760741f to your computer and use it in GitHub Desktop.
nsfetchedresultscontroller with distinct results
let fetchRequest: NSFetchRequest<NSDictionary> = NSFetchRequest(entityName: "Bus")
fetchRequest.propertiesToFetch = ["carreira"]
fetchRequest.returnsDistinctResults = true
fetchRequest.returnsObjectsAsFaults = false
fetchRequest.resultType = NSFetchRequestResultType.dictionaryResultType
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: CoreDataManager.sharedManager.mainContext, sectionNameKeyPath: nil, cacheName: nil) as? NSFetchedResultsController<NSFetchRequestResult>
fetchedResultsController?.delegate = nil
do {
try fetchedResultsController?.performFetch()
} catch {
fatalError("Unable to perform fetch")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment