Last active
November 29, 2017 13:23
-
-
Save premedios/60f50a6027532536574f8fb6c760741f to your computer and use it in GitHub Desktop.
nsfetchedresultscontroller with distinct results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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