How could I fetch distinct values from core data to be shown in UIPicker ?
I've the following code. It works fine but shows duplicate content :
    func CD_Fetch_Value_Database() {
        let context = getcontext()
        let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Calculation")
        fetchRequest.predicate = NSPredicate(format: "test= %@", cd_test)
        fetchRequest.returnsObjectsAsFaults = false
        fetchRequest.returnsDistinctResults = true
    do {
        Value_Database = try context.fetch(fetchRequest) as! [Calculation]
    } catch let error as NSError {
        let errorDialog = UIAlertController(title: "Error!", message: "Failed to save! \(error): \(error.userInfo)", preferredStyle: .alert)
        errorDialog.addAction(UIAlertAction(title: "Cancel", style: .cancel))
        present(errorDialog, animated: true)
    }
}
Thank you!
 
    